Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62152

Menus have wrong size after the window has been moved to a monitor with a differnt DPI

    XMLWordPrintable

Details

    Description

      Let's say there are two monitors A (100% scaling) and B (200% scaling) and your application uses Qt::AA_EnableHighDpiScaling.
      Creating a window with a menu and opening this menu on monitor A looks fine.
      Now move the window to monitor B and open the menu again:
      The menu is way bigger than its content and the following error is logged:

       

      QWindowsWindow::setGeometry: Unable to set geometry 414x252+4188+710 on QWidgetWindow/'QMenuClassWindow'. Resulting geometry: 662x403+4188+710 (frame: 0, 0, 0, 0, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215).

      The same happens in reverse but the menu is cut off. Also, opening the menu again fixes it.

       

      A small repro case:

       

      #include <QApplication>
      #include <QtWidgets>
      
      class MenuWidget : public QMainWindow
      {
      public:
          MenuWidget()
          {
              auto fileMenu = menuBar()->addMenu(tr("&File"));
              fileMenu->addAction("Some File Menu Entry");
              fileMenu->addAction("Some File Menu Entry");
              fileMenu->addAction("Some File Menu Entry");
              fileMenu->addAction("Some File Menu Entry");
              fileMenu->addAction("Some File Menu Entry");
          }
      };
      int main(int argc, char *argv[])
      {
          QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
          QApplication a(argc, argv);
          MenuWidget w;
          w.show();
          return a.exec();
      }
      

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              smd Jan Arve
              christophermanthei Christopher Manthei
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes