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

Add some features to QAction an QMenu

    XMLWordPrintable

Details

    Description

      I suggest to add some features to QMenu and QAction:

      1)  create a signal to intercept a right click on a QAction, to be able to do this for example:

      connect(action, SIGNAL(right_clicked()), this, SLOT(doSomething()));

       

      2) Actually we are able to do set a context menu on a widget but not on an action. My suggestion is to make possible to set a context menu policy on an action. Actually we can do this :

      myWidget->setContextMenuPolicy(Qt::CustomContextMenu);

      connect(myWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));

       

      but not this below. And my suggestion to be able to do ths:

      myAction->setContextMenuPolicy(Qt::CustomContextMenu);

      connect(myAction, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowContextMenu(const QPoint&)));

       

      3) Make possible to hide the right arrow/triangle on a QMenu. The only possibility to hide it today is to make it 0x0 px size with stylesheets: this problem is discussed in many forums like this one: https://forum.qt.io/topic/35113/how-to-hide-the-right-arrow-in-qmenu/6

       

      4) Actually giving a pointer of an action as a parent to a QMenu raise an exceptin at the execution, for example doing this:

       

      QAction* action= new QAction("foo", this);

      QMenu* menu = new QMenu((QWidget*) action);

      raises an exception. My goal was to get the "father" of the menu in the arborescence, since I made this: 

      action->setMenu(menu);

       

      and once the menu open I was not able to know to which action set this menu. There is no function menu->getLinkedAction() or soething like that. So I tried to make this instead:

      QAction* act= new QAction("foo", this);

      QMenu* alpha = new QMenu((QWidget*) act);

      act->setMenu(alpha);

      ....

      //At the slot that manage the context menu "alpha" I wasn't able to this: 

      QAction* act2 = alpha->parent();

       

      because of the excepetion raised at "QMenu* alpha = new QMenu((QWidget*) act);"

       

      My suggestion is to search for solution to make the ability to get the "father" of this QMenu

       

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes