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

QGuiApplication::setHighDpiScaleFactorRoundingPolicy() ignored on Linux, always acts like PassThrough

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.4.0 RC1, 6.5.0 Beta1, 6.6.0
    • 5.15.2, 6.1.2, 6.2.0 Beta3
    • GUI: High-DPI
    • None
    • Broken: Arch Linux, KDE X11, Qt 6.1.2 from Arch, and Qt 6.2.0 beta3 from web installer
      Working: Windows 10 x64, Qt 6.2.0 beta3 from web installer
    • Linux/X11
    • 1c0a56a2f3 (qt/qtbase/dev) 1c0a56a2f3 (qt/tqtc-qtbase/dev) be3f589d17 (qt/qtbase/6.4) be3f589d17 (qt/tqtc-qtbase/6.4), 9a39b3c79 (dev)

    Description

      On Linux (Arch Linux KDE X11 with global fractional scaling enabled), calling QGuiApplication::setHighDpiScaleFactorRoundingPolicy() with a rounding mode fails to change the actual DPI rounding policy. QImage/QPixmap is still painted with non-uniform pixel sizes, and QWidget::devicePixelRatio() is still a non-integer. Fetching the policy using QGuiApplication::highDpiScaleFactorRoundingPolicy() still returns the rounding mode you set, but it doesn't change the app's behavior.

      On Windows, this function works as expected.

      Test app at https://github.com/nyanpasu64/qt6-dpi-fail/tree/device-pixel-ratio (note, not master branch). It calls QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor) and clicking the button prints the current rounding policy and devicePixelRatio. On Windows it's "RoundPreferFloor -> 1", and on Linux it's "RoundPreferFloor -> 1.25".

      EDIT: This issue occurs on any environment where the scale factor is set through QScreen's "_q_scaleFactor" property or the QT_SCREEN_SCALE_FACTORS environment variable, and not on environments where the platform plugin supplies the scale factor.

      Attachments

        1. linux 125% 1.25x.png
          linux 125% 1.25x.png
          98 kB
        2. windows 125% 1.25x.png
          windows 125% 1.25x.png
          37 kB
        3. windows 125% 1x.png
          windows 125% 1x.png
          37 kB

        Issue Links

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

          Activity

            People

              sorvig Morten Sørvig
              nyanpasu64 Nyan Pasu
              Votes:
              1 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes