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. High DPI scaling detection
QtWS25 Last Chance

High DPI scaling detection

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 2.6k Views
  • 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.
  • J Offline
    J Offline
    jazzco2
    wrote on 3 Nov 2021, 08:32 last edited by
    #1

    Hi all,

    I would like to detect the scaling rate of the current display. I checked several values but couldn't find anything helpful:

    DisplayZoom   pixelRatio   physicalDPI   logicalDPI   screenSize   fontSize
      100%            1          108.888         96       2560x1400        8
      125%            1          108.888        120       2560x1390        8
      150%            2           54.4438        96       1280x 690        8
      175%            2           54.4438        96       1280x 685        8
      200%            2           54.4438        96       1280x 680        8
    

    Unlike the menu bar that's scaling correctly several elements like the status bar and text's in the tab widget tend to break out being too big or to small on several systems (Windows, Mac, Linux).

    I read the chapter about High DPI Displays but there's nothing I didn't already tried out.

    Best regards
    Jazzco

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jazzco2
      wrote on 9 Nov 2021, 08:37 last edited by
      #8

      Update:

      The font size of the QMenu and the QTabBar do not differ in the main windows constructor. But after waiting for the followup events to be processed these fonts differ in fact.

      To get the QTabBar having the same font size as the QMenu it doesn't help to just assign the menus font to the it. It is necessary to explicitly assign the pointSize to the font before assigning it to the destination widget (here the QTabBar).

      Additionally one can get the QFontMetrics::height() for concrete values.

      I mark this solved.

      Best
      Jazzco

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 3 Nov 2021, 20:27 last edited by
        #2

        Hi,

        You should add which Qt version as well.

        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
        • J Offline
          J Offline
          jazzco2
          wrote on 4 Nov 2021, 11:03 last edited by jazzco2 11 Apr 2021, 11:04
          #3

          Ah right, it's Qt 5.15.2 - and several versions before that. We won't change to current Qt 6 until the WebEngine is part of it.

          P 1 Reply Last reply 4 Nov 2021, 11:13
          0
          • J jazzco2
            4 Nov 2021, 11:03

            Ah right, it's Qt 5.15.2 - and several versions before that. We won't change to current Qt 6 until the WebEngine is part of it.

            P Offline
            P Offline
            Pl45m4
            wrote on 4 Nov 2021, 11:13 last edited by Pl45m4 11 Apr 2021, 11:14
            #4

            @jazzco2

            Have a look here and here.


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            J 1 Reply Last reply 4 Nov 2021, 12:49
            0
            • P Pl45m4
              4 Nov 2021, 11:13

              @jazzco2

              Have a look here and here.

              J Offline
              J Offline
              jazzco2
              wrote on 4 Nov 2021, 12:49 last edited by
              #5

              @Pl45m4 said in High DPI scaling detection:

              @jazzco2

              Have a look here and here.

              As I told, I already worked through that page. The problems still exist. Therefore the question if there is any value in the libraries of Qt telling what scaling is active on the current display.

              P 1 Reply Last reply 4 Nov 2021, 12:53
              0
              • J jazzco2
                4 Nov 2021, 12:49

                @Pl45m4 said in High DPI scaling detection:

                @jazzco2

                Have a look here and here.

                As I told, I already worked through that page. The problems still exist. Therefore the question if there is any value in the libraries of Qt telling what scaling is active on the current display.

                P Offline
                P Offline
                Pl45m4
                wrote on 4 Nov 2021, 12:53 last edited by Pl45m4 11 Apr 2021, 13:02
                #6

                @jazzco2 said in High DPI scaling detection:

                As I told, I already worked through that page. The problems still exist

                So you must have missed something :)

                Device Pixel Ratio	The scale factor that either the operating system or Qt applies.
                

                This is obtainable from every QWindow as well as from QScreen

                • https://doc.qt.io/qt-5/qscreen.html#devicePixelRatio-prop

                Edit:

                Isn't the pixelRatio already listed in your table? Or am I missing something now? Or I am not getting what you mean?!

                From documentation:

                Common values are 1.0 on normal displays and 2.0 on "retina" displays. Higher values are also possible.
                

                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                J 1 Reply Last reply 4 Nov 2021, 13:22
                0
                • P Pl45m4
                  4 Nov 2021, 12:53

                  @jazzco2 said in High DPI scaling detection:

                  As I told, I already worked through that page. The problems still exist

                  So you must have missed something :)

                  Device Pixel Ratio	The scale factor that either the operating system or Qt applies.
                  

                  This is obtainable from every QWindow as well as from QScreen

                  • https://doc.qt.io/qt-5/qscreen.html#devicePixelRatio-prop

                  Edit:

                  Isn't the pixelRatio already listed in your table? Or am I missing something now? Or I am not getting what you mean?!

                  From documentation:

                  Common values are 1.0 on normal displays and 2.0 on "retina" displays. Higher values are also possible.
                  
                  J Offline
                  J Offline
                  jazzco2
                  wrote on 4 Nov 2021, 13:22 last edited by jazzco2 11 Apr 2021, 13:23
                  #7

                  @Pl45m4 said in High DPI scaling detection:

                  Isn't the pixelRatio already listed in your table?

                  Correct, but as you can see that value doesn't tell what scaling is set up on Windows. There is just a point where it switches from one to two - and there the resolution of the screen is halfed.

                  On startup the QGuiApplication get a font with a pixel-size that somehow reflects the scaling of the primary screen. But that font size isn't updated when the application is moved to a screen with a different scaling factor. Even more puzzling: The texts in the tab-bar and in the menu-bar appear in obvious different sizes - but asking them programatically they claim to have the same point size (the initial point-size of the app)

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jazzco2
                    wrote on 9 Nov 2021, 08:37 last edited by
                    #8

                    Update:

                    The font size of the QMenu and the QTabBar do not differ in the main windows constructor. But after waiting for the followup events to be processed these fonts differ in fact.

                    To get the QTabBar having the same font size as the QMenu it doesn't help to just assign the menus font to the it. It is necessary to explicitly assign the pointSize to the font before assigning it to the destination widget (here the QTabBar).

                    Additionally one can get the QFontMetrics::height() for concrete values.

                    I mark this solved.

                    Best
                    Jazzco

                    1 Reply Last reply
                    0

                    5/8

                    4 Nov 2021, 12:49

                    • Login

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