Qt World Summit: Register Today!

Smoothed icons with high dpi support in Qt app

  • I have enabled high dpi support in my Qt application using QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); but now my images don't look crisp, instead they look "smoothed" out. For example below there is a picture of some button that are meant to be using high dpi images. When I disable the high dpi support and manually scale the ui, using the same images the icons are crisp and clear.

    I have tried to set Qt::AA_UseHighDpiPixmaps with no success.
    Here is a sample code:

    import QtQuick 2.11
    import QtQuick.Window 2.11
    import QtQuick.Controls 2.2
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
            anchors.centerIn: parent
            icon.source: "qrc:/ic_star_white_48dp.png"

    The icon I am using is from Google material design icons and it is made for a high dpi screen device (resolution is 192x192). Enabling high dpi the icon in the toolbutton appears smoothed out. If I disable the high dpi support and set the height and width of the icon (icon.height and icon.width) to 640/160 * 48 (640 is the dpi of my device) the icon is crisp and clear. However, if I enable high dpi and set the height and width to 48, the icon is not crisp.

  • Lifetime Qt Champion


    Did you already saw the related part of QIcon’s documentation ?