Margins for QMenu secondary menus
-
Hi Qt guys from the community, hello! I'm using Qt, but I'm having some issues. QMenu adds a secondary menu, but the display position of the secondary menu may be to the left or right of the primary menu, whether it is left or right, the secondary menu is always pressed and part of the menu, is there any way to adjust? If the inheritance QMenu overrides a class, which methods can control the margins
-
Hi Qt guys from the community, hello! I'm using Qt, but I'm having some issues. QMenu adds a secondary menu, but the display position of the secondary menu may be to the left or right of the primary menu, whether it is left or right, the secondary menu is always pressed and part of the menu, is there any way to adjust? If the inheritance QMenu overrides a class, which methods can control the margins
-
@Nan-Feng
Hi,
you can control where aQMenupops up with
QMenu::exec(position)https://doc.qt.io/qt-6/qmenu.html#exec-1
Or what exactly do you expect?
@Pl45m4 Hi, first of all thank you for taking your time to answer my doubts! The secondary menu pointed out above is a MainMenu added using MainMenu->addMenu method as a first-level menu, QMenu::exec(position) does not seem to control the pop-up position of the secondary menu, and how to get position? The scenario of this menu occurs on the click event of the taskbar tray icon, and the menu is displayed only when the taskbar tray icon is clicked. But how do you get the click position of the tray icon?