Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Popup menu
-
Hello, I am using mousePressEvent to display an option from my menu, I have a condition where if I press the right button of my mouse, one of the options that I have in my menu is displayed. My problem has been that the menu is displayed in the middle of the screen and I would like it to be displayed below the menu option that I am displayed.
thanks.void MainWindow:: mousePressEvent (QMouseEvent * evento)
{
if(evento->buttons() & Qt::RightButton){
QPoint point = ui->menuArchivo->pos();
ui->menuArchivo->popup(point);
}
}
-
you want to display the Popup menu at any position of the screen Right ?
-
@Ketan__Patel__0011
no, I want the actions within a qmenu to appear below the menu option in questionI get this:
I need this:
-
Hi,
From your drawing it seems you want a normal menu to be shown as when you left click on a menu.
Do you mean you only want to change one menu entry when right clicking ?
-
@SGaist Hello, I want that when I press the right click anywhere on my screen it appears the same as the second image.
-
From your second image it seems you have clicked on the Archivo menu. Is that the effect you want ?
Note that this behaviour is going to disturb your users. If I right click somewhere on an application I certainly would think it's a bug that a menu opens like that rather than a contextual menu under the mouse pointer.
-
@SGaist yes that's the effect i want.
-
What if you call the menu's
popupexec method with no parameters ?
-
@SGaist what do you mean, can you explain me please?
-
Sorry I meant exec.