Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74506

When adding a menu to an action, you cannot click (trigger) anymore on this action.

    XMLWordPrintable

    Details

      Description

      When adding a menu to an action, you cannot click (trigger) anymore on this action.

      For example, after doing something like this on a QMainWindow:

      ui.baseMenu->addAction(myAction);
      QMenu* myMenu();
      myAction->setMenu(myMenu);
      connect(myAction, SIGNAL(triggered()), this, SLOT(doSomething()));}}{{

      //...

      void MyClass::doSomething()

      {{{}}

      }

      when the window is displayed, you cannot click and trigger myAction, and the programm will never enter into doSomething() slot. And this problem is because we've setted a QMenu to our QAction (myAction->setMenu(myMenu);

      I don't know if its a bug or a wanted behavior, but my suggestion is to add an option in order to let the programmer user define if he wants to make the menu myMenu masking the triggerable action or not. 

      The solution may like something like this (example of possible solution): 

      ui.baseMenu->addAction(myAction);
      QMenu* myMenu();
      myMenu->setMaskingAssociatedAction(false);
      myAction->setMenu(myMenu);

      //etc...

      This is only an example, the goal is to solve this problem anyway. 

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            • Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              navis-raven Dragoon Gryffoon
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes