Manages Python function invocation through Qt signals. And connection of Qt signals to Python functions or QObject methods. More...
#include <PyCallbackDispatcher.h>
Public Member Functions | |
PyCallbackDispatcher (QObject *parent=0) | |
Standard QObject constructor. | |
PyCallbackDispatcher (PyContext *pc, PyObject *pm, QObject *parent=0) | |
Constructor, bind dispatcher to Lua context. | |
int | qt_metacall (QMetaObject::Call c, int id, void **arguments) |
bool | Connect (QObject *obj, int signalIdx, const CBackParameterTypes ¶mTypes, PyCBack pyCBack, PyObject *module) |
bool | Disconnect (QObject *obj, int signalIdx, PyCBack pyCBack) |
void | SetPyContext (PyContext *pc) |
Set Python context. | |
virtual | ~PyCallbackDispatcher () |
Destructor: Clear method database. |
Manages Python function invocation through Qt signals. And connection of Qt signals to Python functions or QObject methods.
Exposes methods to connect Qt signals emitted from QObjects to Python functions or other QObject methods. Whenever a new signal -> Python connection is requested a new proxy method is generated and the signal is routed to the new method which in turn takes care of invoking the Python function. Note that when disconnecting a signal the associated method is not currently removed from the method array because signals are connected to methods through the method's position in the method array, thus removing a method from the array invalidates all the signal to method connections for which the method index is greater than the one of the removed method.
bool qpy::PyCallbackDispatcher::Connect | ( | QObject * | obj, |
int | signalIdx, | ||
const CBackParameterTypes & | paramTypes, | ||
PyCBack | pyCBack, | ||
PyObject * | module | ||
) |
Connect signal to Python function
module | Python module; used in case new QObjects need to be added as result of triggered signals |
obj | source QObject |
signalIdx | signal index |
paramTypes | signal signature |
pyCBack | reference to Python target function |
bool qpy::PyCallbackDispatcher::Disconnect | ( | QObject * | obj, |
int | signalIdx, | ||
PyCBack | pyCBack | ||
) |
Disconnect signal from Python function
obj | source QObject |
signalIdx | signal index |
pyCBack | Python function |
int qpy::PyCallbackDispatcher::qt_metacall | ( | QMetaObject::Call | c, |
int | id, | ||
void ** | arguments | ||
) |
Overridden method: This is what makes it possible to bind a signal to a Python function through the index of a proxy method.