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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2, 6.1.2, 6.2.0 Beta3
    • Fix Version/s: None
    • Component/s: GUI: High-DPI
    • Labels:
      None
    • Environment:
      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
    • Platform/s:
      Linux/X11

      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
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes