Question

I Have a (QT) toolbar in my application which is populated by QAction objects, and one of the QActions has an associated menu. I would like to pop up that menu below the QActions' button when the action is triggered.

I have tried:

m_ui->action_NewDataType->menu()->show();

but this shows the menu on the left upper corner of the screen, instead of where I want it. How can I show the menu below the QAction button, nicely aligned to the edges of the button?

Was it helpful?

Solution

problem solved:

 QWidget* w = m_ui->mainToolBar->widgetForAction(m_ui->action_NewDataType);
 m_ui->action_NewDataType->menu()->popup(w->mapToGlobal(QPoint(0, w->height())))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top