[Solved] QGLWidget Popup menu: QAction not clickable
-
Hi,
I've written a simple OpenGL renderer (overriding QGLWidget class) and I've overrided the mouseReleaseEvent function to show a popup menu when I right click. This is the method:@
void myViewer::mouseReleaseEvent ( QMouseEvent * event )
{
if(event->button() == Qt::RightButton)
{
QMenu *menu = new QMenu("&Menu",this);QAction* action_1 = new QAction("&A", this); QAction* action_2 = new QAction("&B", this); QAction* action_3 = new QAction("&C", this); menu->addAction(action_1); menu->addAction(action_2); menu->addAction(action_3); connect(action_1, SIGNAL(triggered()), this, SLOT(slot_action_1())); connect(action_2, SIGNAL(triggered()), this, SLOT(slot_action_2())); connect(action_3, SIGNAL(triggered()), this, SLOT(slot_action_3())); menu->exec(mapToGlobal(event->pos())); delete menu; }
}
@The menu is shown as expected but when I try to click a menu item this seems inactive and the corresponding slot isn't called. What's wrong with this? I thought it was a focus problem but I wrote a similar code for a QTextEdit and it worked fine. I'm using Qt 4.6 on MS Visual Studio 2008 pro.
Thanks!
Marco
-
I solved! You can close this post!
-
Sure but I'm ashamed: I did a trivial error missing Q_OBJECT macro in myViewer header file!