Gui::ActionFunction Class Reference

#include <ActionFunction.h>

Public Member Functions

 ActionFunction (QObject *)
 Constructor. More...
 
void hover (QAction *a, boost::function< void()> func)
 
void toggle (QAction *a, boost::function< void(bool)> func)
 
void trigger (QAction *a, boost::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, boost::bind(&MyViewProvider::doItem1, this));
QAction* a2 = menu->addAction(QObject::tr("Menu item 2..."));
func->triggered(a2, boost::bind(&MyViewProvider::doItem2, this));
QAction* a3 = menu->addAction(QObject::tr("Menu item 3..."));
func->triggered(a3, boost::bind(&MyViewProvider::doItem3, this));
}
Definition: ActionFunction.h:65
def bind(w1, w2)
Definition: faces.py:113
a2
Definition: NavigationIndicatorGui.py:345
a3
Definition: NavigationIndicatorGui.py:351
a1
Definition: NavigationIndicatorGui.py:339
menu
Definition: NavigationIndicatorGui.py:304
Author
Werner Mayer

http://www.boost.org/doc/libs/1_57_0/libs/bind/bind.html#with_boost_function

Constructor & Destructor Documentation

◆ ActionFunction()

ActionFunction::ActionFunction ( QObject parent)

Constructor.

◆ ~ActionFunction()

ActionFunction::~ActionFunction ( )
virtual

Member Function Documentation

◆ hover()

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

◆ toggle()

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

◆ trigger()

void ActionFunction::trigger ( QAction *  a,
boost::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:
  • Sources/FreeCAD/src/Gui/ActionFunction.h
  • Sources/FreeCAD/src/Gui/ActionFunction.cpp