Adding a QAction to a QMenu on a certain position
In my app I have a QWidget that has as a parent a QMenu. I want to add an QAction on that menu under QWidget. Do you know how to position my QAction on a certain spot into the menu? The only solution seems to add fake actions to that menu till my QAction become visible…
I think that a QAction::setGeometry() can be useful in this case…
4 replies
- menu->setMinimumHeight( 140 );
- menu->setMinimumWidth( 152 );
- button->setMenu( menu);
- widget->setGeometry( 0, 0, 152, 113 );
now I would like to add a QAction to my menu under the widget but all I can do is:
my action here it’s not visible because the widget overlapped it, so to became visible I was needed to do:
- /* add fake actions till the wanted action is visible*/
- menu->addAction( fakeAction );
- /* add the wanted action at the end*/
- menu->addAction( action );
I would like to have :
- action->setGeometry( 0,113,152,140 );
- //or
- menu->addAction( action, indexPositionInMenu );//if we can't have different heights for more actions
You must log in to post a reply. Not a member yet? Register here!




