hivemind 1.0.0
Loading...
Searching...
No Matches
Gui::Action Class Reference

Small wrapper around QAction. More...

#include <action.h>

Inheritance diagram for Gui::Action:
Inheritance graph
Collaboration diagram for Gui::Action:
Collaboration graph

Public Member Functions

 Action (QWidget *parent, const QString &label, void(*onClick)(void), const QKeySequence &shortcut=QKeySequence::UnknownKey)
 Constructs the Action widget.
 

Detailed Description

Small wrapper around QAction.

A tiny wrapper class around QAction that simply provides constructor arguments to add on-click functionality and keyboard shortcuts.

Definition at line 12 of file action.h.

Constructor & Destructor Documentation

◆ Action()

Gui::Action::Action ( QWidget *  parent,
const QString &  label,
void(*)(void)  onClick,
const QKeySequence &  shortcut = QKeySequence::UnknownKey 
)

Constructs the Action widget.

Parameters
parentThe parent of the Action widget.
labelThe label to be displayed in the action.
onClickA function to call when the action is clicked.
shortcutA keyboard shortcut to activate the action.

Typical usage:

Action* openAction = new Action(
parent, QString::fromUtf8("Open..."),
[]() {
QString fileName = QFileDialog::getOpenFileName(
nullptr, QString::fromUtf8("Open Image"),
QDir::currentPath(),
QString::fromUtf8("Image Files (*.png *.jpg *.bmp)"));
qInfo() << "File: " << fileName;
},
QKeySequence::Open);
Small wrapper around QAction.
Definition: action.h:13

Definition at line 9 of file action.cpp.


The documentation for this class was generated from the following files: