Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMenu opens first time off screen
Forum Updated to NodeBB v4.3 + New Features

QMenu opens first time off screen

Scheduled Pinned Locked Moved General and Desktop
qmenuc++
9 Posts 4 Posters 2.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheBigOnion2
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheBigOnion2
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TheBigOnion2
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lman
              wrote on last edited by
              #6

              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();
              }
              
              
              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You should try with a recent version of Qt.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lman
                  wrote on last edited by
                  #8

                  Hi. Thanks for the speedy response.
                  I installed Qt 6.7.2. The behaviour is still as described above.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Then please provide a bug report (search first if the issue is already reported): bugreports.qt.io

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved