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

QGuiApplication doesn't sync to display resolution changes when starting with all widgets hidden

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14, 5.15
    • GUI: High-DPI
    • None
    • Windows

    Description

      QGuiApplication::primaryScreen and changing the display resolution before any widgets are shown

      For systray applications with widgets created in a hidden state the following scenario might be of relevance: When changing the primary display's resolution before any of the created widgets are shown, QGuiApplication does not update the primary QScreen's data. So when the first widget shows up, and the resolution was changed after the creation of QApplication and before the first show event, QGuiApplication::primaryScreen() has the wrong display data even after the following show events. The only way to update QGuiApplication::primaryScreen() is to change the primary display's resolution after the first show event.

      In that scenario for getting the primary screen's data the following calls are used:

      QGuiApplication::sync();
      QScreen *screen = QGuiApplication::primaryScreen();
      

      Affects Versions

      Versions Qt 5.14.0, 5.15.0 and 5.15.1 are affected by the problem.

      Description

      How to reproduce the problem

      The testcase project is contained in the attached zip file:

      qtbug89159_resolutionbug.zip
      1. Create the project with cmake from the attached example zip file (tested configuration: generator of project: Visual Studio 14 2015, Optional platform for generator: x64, select option 'Use default native compilers', Qt5_DIR: cmake/qt5 of Qt 5.15.1)
      2. Compile project (if Visual Studio was configured as the generator: open qt_resolution.sln, build the whole solution, set qt_resolution as the startup project, copy qt dlls and plugin/platforms folder into the bin directory manually)
      3. Set the display resolution to a size A with smaller than native height for the system before starting the executables (example: primary screen has native resolution B = 1920x1080, set resolution A = 1366x768 for the system)
      4. Start the executable ./bin/qt_resolution. A System Tray Icon with a green dot for its icon appears. Don't click on it yet, if any widget (including the tray icon's menu) opens now, the testcase won't work.
      5. Set the resolution to native size B for the system (example: go from resolution A = 1366x768 to native resolution B = 1920x1080)
      6. Open the System Tray Icon's menu by right clicking on it. A menu with actions 'Show Notifications' and 'Exit' opens. Click on menu point 'Show Notifications'.
      7. A borderless widget with title 'Notifications' and text 'Display data' opens. Under 'Display data' the properties of the primary screen are displayed. They are refreshed each time the 'Notifications' widget opens by calling QGuiApplication::sync() and then QGuiApplication::primaryScreen().
      8. Observe that below 'Display data' right from 'size' resolution A instead of the currently set resolution B is shown. Apart from that the 'Notifications' widget is positioned in the middle of the screen, but it is supposed to touch the top, bottom and right of the primary screen with its top, bottom and right.
      9. Close the 'Notifications' widget with the ToolButton 'Close' on the top right of the widget. Set Resolution A, and then Resolution B.
      10. Open the 'Show Notifications' widget like in point 6. Observe that right from 'size' the correct resolution B is displayed. The 'Notifications' widget is now correctly positioned such that it touches the top, bottom and right of the primary screen with its top, bottom and right.

      Environment

      For details of the platform see

      qtdiag.txt
      
      • Qt 15.5.1, x64
      • MS Visual Studio Professional 2015 (Version 14, Update 3)
      • Cmake 3.14.3
      • Windows 10 x64 (Version 2009)

      Attachments

        1. OpenDialog.png
          25 kB
          Tristan Bauer
        2. qtbug89159_resolutionbug.zip
          6 kB
          Tristan Bauer
        3. qtdiag.txt
          22 kB
          Tristan Bauer
        4. WrongResolution.png
          672 kB
          Tristan Bauer
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            tristanb Tristan Bauer
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes