Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QGLWidget Popup menu: QAction not clickable
QtWS25 Last Chance

[Solved] QGLWidget Popup menu: QAction not clickable

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ilPropheta
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ilPropheta
      wrote on last edited by
      #2

      I solved! You can close this post!

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Could you please tell us what was wrong? That could help others after you.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ilPropheta
          wrote on last edited by
          #4

          Sure but I'm ashamed: I did a trivial error missing Q_OBJECT macro in myViewer header file!

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            I tried your code snip and it worked just fine, so didn't dig further ...

            [quote author="ilPropheta" date="1287411976"]Sure but I'm ashamed: I did a trivial error missing Q_OBJECT macro in myViewer header file! [/quote]
            happens to all of us :P

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved