Qt World Summit: Submit your Presentation

High DPI and native presentation of images

  • Hi all,

    I am using a 4K monitor with Qt High DPI. I am using the following attributes to get High DPI enabled.

    QApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
    QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps );

    On Windows I use 175% or 200% scaling and alignment. With these settings, my application can be displayed with a scaling factor of 2. Funny thing, even with 175% or 150% I get a scaling factor of 2, so I thing the scaling factor are integer numbers.
    I have some kind of an image viewer and the images should be displayed with 100% size, but Qt transformed these images also with the scaling factor. So the native images are displayed with 200%.

    Is there a way that Qt won't scale images that are painted in a paint event?
    Or how do I get the information about the current scaling factor that Windows is currently using?


  • I found a solution myself.

    When drawing the image I can get the current screen and its device pixel ratio. This is the current scaling factor Windows is using.
    With this factor I can scale the image to the current size.


Log in to reply