Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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?

    regards
    Oliver



  • 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.

    regards
    Oliver


Log in to reply