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. QT_ENABLE_HIGHDPI_SCALING misbehaving when windows scaling is set to 200%
Forum Updated to NodeBB v4.3 + New Features

QT_ENABLE_HIGHDPI_SCALING misbehaving when windows scaling is set to 200%

Scheduled Pinned Locked Moved Unsolved General and Desktop
high dpiscalingscaledqradiobuttondisplay
7 Posts 4 Posters 205 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.
  • J Offline
    J Offline
    Jammin44fm
    wrote last edited by
    #1

    Hi all,

    Qt 6.5.3, Windows 10.

    I'm getting some very strange results when combining large scale factors.
    Most notably I am seeing different elements scale themselves differently, and it looks very strange when displayed.

    Perhaps the most obvious one is a collection of radio buttons.

    This is the radio buttons with windows scaling @ 100%, and no Application scaling
    windows scaling 100 No App scaling.png

    This is windows scaling @ 100% and 200% application scaling, it seems correct at about 2x in both directions.
    windows scaling 100 App scaling 200.png

    This is windows scaling @ 200% and No app Scaling, again basically correct with a 2x in each direction.
    windows scaling 200 No App scaling .png

    This is the Problem.
    Windows scaling @ 200% and app scaling @ 200%, whilst the text appears to be the correct size, the size of the actual radio button icon is much larger than it should be and throws off the rest of the placement and layout.
    windows scaling 200 App scaling 200.png

    I am using the following code to disable the host OS scaling and force my own scaling, as required.

    float ratio = 0; // 2.0;
    if(ratio > 0)
    {
        qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");      // Disable host OS scaling
        if(ratio > 1.0)
            qputenv("QT_SCALE_FACTOR", QString::number(ratio).toLatin1());
    }
    
    Application app(argc, argv);
    return app.exec();
    

    So when I am doing application scaling i am setting the QT_ENABLE_HIGHDPI_SCALING to 0, to disable the Host scaling.
    Now for the most part this seems to be working as expected, it is just in a few items that I run into this problem.
    Other places I have run into a similar issue, are with a QLineEdit, that seems to be taller than it should be,
    and a QLabel which is also being drawn too tall.

    Am I doing something wrong with my usage of QT_ENABLE_HIGHDPI_SCALING ?
    It seems to be behaving as expected for most use cases, ie if I have my windows scaling set to 150%, and my application scaling set to 125%
    I get the 125% from my app with no extra windows scaling. Again if windows is @ 150%, and my app is at 125% i get the resulting 125% scale as expected.
    Are there some extra rules I am not aware of when laying out GUI items for this sort of usage?

    Lastly I have tested the dprgadget sample app as provided as part of the SDK / Creator examples, and it too throws up some unusual behavior.
    I modified the dprgadget app to have the same custom scaling as my app, prior to init'ing the QApplication and showing the DprWidget itself.
    I then recorded the QWindow size and native size values from the displayed application.

    Here are my results:

    		QWindow size	nativeSize
    
    Windows 100%	457, 431	457,431
    NO App scaling
    
    Windows 100%	458, 438	916,876
    2.0 App scaling
    
    Windows 200%	458, 438	916,876
    No App scaling
    
    Windows 200%	 916, 860	1832, 1720
    2.0 App scaling 
    

    Pasted as code to preserve some of the formatting.
    So again, the last example clearly has some problems with the way it is calculating the size of the window?
    It still displays a big fat 2, but it looks like, and the numbers indicate it's scaling more like 4x than 2x?

    So it looks to me like in some situations the host OS is not being correctly disabled or ignored by the Qt rendering code? But I'm just making a wild guess?

    Regards,
    James

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

      Hi,

      Can you check with a more recent version of Qt ?
      If memory serves well, there have been multiple fixes for high dpi.

      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
        Jammin44fm
        wrote last edited by
        #3

        I've checked with a newer version of Qt, specifically Qt 6.8.3.
        and the same problem persists :(
        If anything it's possibly worse.
        The windows 200% and 2.0 for app scaling window is so large I cant even see the part of the dialog where it displays the native size.

        jsulmJ 1 Reply Last reply
        0
        • J Jammin44fm

          I've checked with a newer version of Qt, specifically Qt 6.8.3.
          and the same problem persists :(
          If anything it's possibly worse.
          The windows 200% and 2.0 for app scaling window is so large I cant even see the part of the dialog where it displays the native size.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote last edited by
          #4

          @Jammin44fm Latest Qt version is 6.9.1

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote last edited by
            #5

            I don't see a problem with your numbers. 45722=1828 which matches more or less your 1832.
            Qt does not ignore anything here.
            please provide a minimal compileable example of your problem.

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

            J 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              I don't see a problem with your numbers. 45722=1828 which matches more or less your 1832.
              Qt does not ignore anything here.
              please provide a minimal compileable example of your problem.

              J Offline
              J Offline
              Jammin44fm
              wrote last edited by
              #6

              @Christian-Ehrlicher

              Can you elaborate on "Qt does not ignore anything here."
              The docs at high dpi state...
              "QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; "
              I took this to mean that no OS level scaling will be applied.
              That is, my application will fully ignore whatever setting the user has specified in windows for the scale setting for that display.

              Perhaps I am wrong though? However, If this is the case I would have expected the last picture I provided to be a full 4x the width and height of the original image?

              Looking at the value displayed by dprgadget, it is always either 1 or 2, never 4.
              In my case of windows scaling set to 200% and application scaling set to 2.0,
              I would expect it to display 4, which would make sense with the 4x in length and width,
              but it still shows 2?
              It seems like the value displayed can account for the Host OS scaling level OR, the QT_SCALE_FACTOR value set, but not for both. However the final size of the window displayed IS effected by both these values.

              Christian EhrlicherC 1 Reply Last reply
              0
              • J Jammin44fm

                @Christian-Ehrlicher

                Can you elaborate on "Qt does not ignore anything here."
                The docs at high dpi state...
                "QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; "
                I took this to mean that no OS level scaling will be applied.
                That is, my application will fully ignore whatever setting the user has specified in windows for the scale setting for that display.

                Perhaps I am wrong though? However, If this is the case I would have expected the last picture I provided to be a full 4x the width and height of the original image?

                Looking at the value displayed by dprgadget, it is always either 1 or 2, never 4.
                In my case of windows scaling set to 200% and application scaling set to 2.0,
                I would expect it to display 4, which would make sense with the 4x in length and width,
                but it still shows 2?
                It seems like the value displayed can account for the Host OS scaling level OR, the QT_SCALE_FACTOR value set, but not for both. However the final size of the window displayed IS effected by both these values.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote last edited by
                #7

                @Jammin44fm said in QT_ENABLE_HIGHDPI_SCALING misbehaving when windows scaling is set to 200%:

                QT_ENABLE_HIGHDPI_SCALING

                "This variable is intended for testing purposes only, and we do not recommend setting it on a permanent basis."

                So don't use it...

                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