Gui::ActionFunction Class Reference

#include <ActionFunction.h>

Public Member Functions

 ActionFunction (QObject *)
 Constructor. More...
void hover (QAction *a, std::function< void()> func)
void toggle (QAction *a, std::function< void(bool)> func)
void trigger (QAction *a, std::function< void()> func)
virtual ~ActionFunction ()

Detailed Description

The class connects the triggered() signal of a QAction instance with the method of a usual C++ class not derived from QObject.

The class can e.g be used to fill up the context-menu of the view provider classes.

void MyViewProvider::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
QAction* a1 = menu->addAction(QObject::tr("Menu item 1..."));
func->triggered(a1, std::bind(&MyViewProvider::doItem1, this));
QAction* a2 = menu->addAction(QObject::tr("Menu item 2..."));
func->triggered(a2, std::bind(&MyViewProvider::doItem2, this));
QAction* a3 = menu->addAction(QObject::tr("Menu item 3..."));
func->triggered(a3, std::bind(&MyViewProvider::doItem3, this));
Werner Mayer

Constructor & Destructor Documentation

◆ ActionFunction()

ActionFunction::ActionFunction ( QObject parent)


◆ ~ActionFunction()

ActionFunction::~ActionFunction ( )

Member Function Documentation

◆ hover()

void ActionFunction::hover ( QAction *  a,
std::function< void()>  func 

◆ toggle()

void ActionFunction::toggle ( QAction *  a,
std::function< void(bool)>  func 

◆ trigger()

void ActionFunction::trigger ( QAction *  a,
std::function< void()>  func 

Connects the QAction's triggered() signal with the function func

References draftgeoutils.intersections::connect().

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