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. Qt6 and QT_ENABLE_HIGHDPI_SCALING
Forum Updated to NodeBB v4.3 + New Features

Qt6 and QT_ENABLE_HIGHDPI_SCALING

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 120 Views 1 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.
  • A Offline
    A Offline
    AndyE0
    wrote last edited by AndyE0
    #1

    From the 6.9 docs:

    QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; effectively reverting to Qt 5 default behavior. Note that this has no effect on platforms such as Wayland or macOS - it does not disable any native high-DPI support. This variable is intended for testing purposes only, and we do not recommend setting it on a permanent basis.

    I am porting an MFC application to Qt which has no High DPI awareness.

    I have placed this line of code before creating the QApplication instance:

    qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
    

    Which seems to make no difference as the moment the application instance is created all scaling disappears.

    Any ideas?

    Edit: When I say all scaling disappears, I mean the Windows Scale setting in System->Display (Windows 11 by the way)

    jsulmJ 1 Reply Last reply
    0
    • A AndyE0

      From the 6.9 docs:

      QT_ENABLE_HIGHDPI_SCALING Set to 0 to disable high-dpi scaling; effectively reverting to Qt 5 default behavior. Note that this has no effect on platforms such as Wayland or macOS - it does not disable any native high-DPI support. This variable is intended for testing purposes only, and we do not recommend setting it on a permanent basis.

      I am porting an MFC application to Qt which has no High DPI awareness.

      I have placed this line of code before creating the QApplication instance:

      qputenv("QT_ENABLE_HIGHDPI_SCALING", "0");
      

      Which seems to make no difference as the moment the application instance is created all scaling disappears.

      Any ideas?

      Edit: When I say all scaling disappears, I mean the Windows Scale setting in System->Display (Windows 11 by the way)

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote last edited by
      #2

      @AndyE0 said in Qt6 and QT_ENABLE_HIGHDPI_SCALING:

      When I say all scaling disappears, I mean the Windows Scale setting in System->Display (Windows 11 by the way)

      Do you mean that setting in Windows settings is disabled?
      You did not say what problem you're trying to solve.
      Also, keep in mind that QT_ENABLE_HIGHDPI_SCALING is for testing purposes only as stated in the doc you cited.

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

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @AndyE0 said in Qt6 and QT_ENABLE_HIGHDPI_SCALING:

        When I say all scaling disappears, I mean the Windows Scale setting in System->Display (Windows 11 by the way)

        Do you mean that setting in Windows settings is disabled?
        You did not say what problem you're trying to solve.
        Also, keep in mind that QT_ENABLE_HIGHDPI_SCALING is for testing purposes only as stated in the doc you cited.

        A Offline
        A Offline
        AndyE0
        wrote last edited by
        #3

        @jsulm said in Qt6 and QT_ENABLE_HIGHDPI_SCALING:

        You did not say what problem you're trying to solve.
        Also, keep in mind that QT_ENABLE_HIGHDPI_SCALING is for testing purposes only as stated in the doc you cited.

        I want to turn off that setting (so reverting to Qt5 behaviour).

        At the moment...

        • MFC app starts up and displays ok (manifest says no dpi awareness)
        • QApplication is instantiated
        • MFC app is no longer scaled at 150% (150% being the system setting)

        Currently, that line of code appears to make no difference.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote last edited by
          #4

          If you right-click on the .exe file, select Properties and in the Compability tab click the "Change high DPI settings" button, does any setting in that dialog box help the faulty scaling after QApplication is instantiated?

          A 1 Reply Last reply
          0
          • hskoglundH hskoglund

            If you right-click on the .exe file, select Properties and in the Compability tab click the "Change high DPI settings" button, does any setting in that dialog box help the faulty scaling after QApplication is instantiated?

            A Offline
            A Offline
            AndyE0
            wrote last edited by
            #5

            @hskoglund said in Qt6 and QT_ENABLE_HIGHDPI_SCALING:

            If you right-click on the .exe file, select Properties and in the Compability tab click the "Change high DPI settings" button, does any setting in that dialog box help the faulty scaling after QApplication is instantiated?

            Thanks for the suggestion but I think those settings effectively override the manifest (so startup only) and indeed I can change the setting on an exe so that it "supports" High DPI even when it doesn't and start it up and you can see scaling issues. Reverting it while it's running makes no difference.

            However, this is now moot as I decided to suck it up and change the legacy code to check for and support the system scaling. We have a fair number of these MFC apps and on some this will be a lot more work than others. This one is not too bad as the main client window is written using our Direct2D library which already supports such scaling. As expected Windows common controls support this out of the box and weirdly all our MFC dialogs also display scaled with the only apparent issue being the font text display appearing "thin" and somewhat faded. Not enough of a problem to care about.

            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