I have a node (the typename doesn't matter here) inheriting from QObject. It has a void contextMenuEvent(const QPoint& p) called from the view (first block of code) and the setupMenu() is also a member of this class. The puzzling thing is that I tried substituting signal/slots with QMetaObject::invokeMethod but it did not give any result either...
EDIT :
Yeah!!! I've solved it! My fix is (very) dirty but inheritance-aware as I needed and AFAIK the Trolls have no reason changing the syntax of the meta-object system before a while...
I suppose the problem comes from the fact that my nodes are created in a separate thread (to avoid GUI freeze) which gets destroyed afterward (thus no event loop is running). So I added a "QHash<QAction*, const char*> slot_table;" member which is filled in the setupMenu() method with appropriate action-method name pairs. Then, after menu execution I use the following code :
if ( a && slot_table.contains(a) )
{
int idx = metaObject()->indexOfSlot(slot_table[a]);
}
QAction *a = m.exec(p);
if ( a && slot_table.contains(a) )
{
int idx = metaObject()->indexOfSlot(slot_table[a]);
qt_metacall(QMetaObject::InvokeMetaMethod, idx, 0);
}
To copy to clipboard, switch view to plain text mode
Bookmarks