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

Add some features to QAction an QMenu




      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 :


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


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


      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: 



      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);



      //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



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



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



              Gerrit Reviews

                There are no open Gerrit changes