In a custom tree model I have enabled context menu handling at node level and the code looks like that :
Qt Code:
  1. pMenu = new QMenu("Actions");
  2. setupMenu(pMenu);
  3.  
  4. QAction *a = pMenu->exec(p);
  5.  
  6. qDebug("action triggered : %s", a ? qPrintable(a->text()) : "");
  7. //pMenu->deleteLater();
  8.  
  9. if ( a )
  10. a->trigger();
To copy to clipboard, switch view to plain text mode 

setupMenu() is a virtual function that is in charge of setting up the menu content :
Qt Code:
  1.  
  2. a = new QAction(QIcon(":/"), tr("&Remove"), m);
  3. connect(a , SIGNAL( triggered() ),
  4. this, SLOT ( deleteLater() ) );
  5.  
  6. m->addAction(a);
  7.  
  8. m->addSeparator();
  9.  
  10. a = new QAction(QIcon(":/folder.png"), tr("A&dd folder"), m);
  11. connect(a , SIGNAL( triggered() ),
  12. this, SLOT ( addFolder() ) );
  13.  
  14. m->addAction(a);
  15.  
  16. a = new QAction(QIcon(":/add.png"), tr("Add &file"), m);
  17. connect(a , SIGNAL( triggered() ),
  18. this, SLOT ( addFile() ) );
  19.  
  20. m->addAction(a);
  21.  
  22. a = new QAction(QIcon(":/file.png"), tr("&New file"), m);
  23. connect(a , SIGNAL( triggered() ),
  24. this, SLOT ( newFile() ) );
  25.  
  26. m->addAction(a);
  27.  
  28. m->addSeparator();
  29.  
  30. a = new QAction(QIcon(":/clear.png"), tr("&Clear"), m);
  31. connect(a , SIGNAL( triggered() ),
  32. this, SLOT ( clear() ) );
  33.  
  34. m->addAction(a);
To copy to clipboard, switch view to plain text mode 

When I play with my model on a QTreeView the context menu gets displayed correctly. Then if I trigger an action by clicking on a menu item I get a correct message on the console output ( i.e : "action triggered : x") but the triggered signal is never emitted (or never forwarded to the slots I have connected to it even when I call trigger() programmatically ...

I'm using Qt 4.2.2 under Linux. Any hints???