QMenu opens first time off screen
-
Hello,
I have a QMenu that is loaded from a model. It is used very much like the older Windows Start button. When I click my QPushButton the menu appears above it. This works perfectly. But when I go to the top of the menu and mouse over "Programs" which opens a sub-menu to the right. The new sub-menu opens but is positioned too low. The bottom of it goes over the task bar and a little bit off the screen. If I move my mouse and then hover over "Programs" again, the sub-menu positions itself correctly.I have searched long and wide and cannot find a resolution for this. Can someone please shed some light on this for me?
-
Hi and welcome to devnet,
What version of Qt are you using ? On which OS ?
Can you provide a minimal compilable example that reproduces this ?
-
Hi,
I'm on RHEL 6 and QT 4. I cannot really post the code as I would have to post my whole application. And I do not know what specific code controls the position of the menu. (thus my question).Thanks for the help.
-
That's one of the reason of making a minimal example. You can put in it just the part that create the QMenu and test it there
-
I really just need to know if someone has had this same problem and what they did to fix it.
Or, what the method/property is on the menu to check/set the starting position. -
This is an old post but I ran into the same thing with a submenu on a system tray icon.
My system is opensuse leap 15.3 running kde. Qt version 5.12.7. I also compiled with Qt 6.2.2 - no change in behaviour
Below is a minimal application which shows the problem
After starting an icon should appear in the system tray. The problem:
Right click on the icon and move the mouse up to "sub". The submenu will open but not all items are accessible - part of the menu is "off screen" !
Now move the mouse up to "item" and back down to "sub". The submenu is now perfect - all items visible.
After this the menu is always visible until the application is restarted.Code:
#include <QApplication> #include <QSystemTrayIcon> #include <QMenu> #include <QIcon> int main(int argc, char **argv) { QApplication app(argc, argv); QIcon icon = QIcon::fromTheme("document-open"); QSystemTrayIcon* sti = new QSystemTrayIcon(icon); sti->show(); QMenu *menu = new QMenu; menu->addSeparator(); menu->addAction("item"); QMenu* submenu = new QMenu("sub"); submenu->addAction("s1"); submenu->addAction("s2"); submenu->addAction("s3"); submenu->addAction("s4"); submenu->addAction("s5"); menu->addMenu(submenu); sti->setContextMenu(menu); return app.exec(); }
-
You should try with a recent version of Qt.
-
Then please provide a bug report (search first if the issue is already reported): bugreports.qt.io