Qt World Summit: Submit your Presentation

Qt 6.0.3 QFileIconProvider and High DPI

  • When using QFileIconProvider to retrieve a QIcon from an executable on Windows, I can't use the icon on a pushButton with scaling settings other than 100% (it's simply not displayed at all).

    I've created a small sample for demonstration:

    void MainWindow::on_pushButton_clicked()
        QFileInfo *test = new QFileInfo("C:/Qt/MaintenanceTool.exe");
        QFileIconProvider *provider = new QFileIconProvider;
        QIcon icon = provider->icon(*test);
        QPixmap pixmap = icon.pixmap(icon.actualSize((QSize(1024,1024))));
        qDebug() << icon.availableSizes() << pixmap;

    Console output when scaling is set to 100% is:

    QList(QSize(16, 16), QSize(32, 32)) QPixmap(QSize(32, 32),depth=32,devicePixelRatio=1,cacheKey=0x5300000001)

    Console output when scaling is set to anything but 100%:

    QList(QSize(24, 24), QSize(48, 48)) QPixmap(null)

    I suspect this has to do with the way Qt handles Icons with high DPI displays but I obviously can't provide high DPI icons.
    Is this a bug or did I miss something?

  • Lifetime Qt Champion


    You mean the windows text scale ?
    alt text

    Icon did show using Qt 5.15.1
    using your code. ( also at 125% etc)

  • @mrjj Yes and yes. This only happens in 6.0.3.
    5.15 doesn’t scale the app (by default).

  • I’m surprised you get the icon at 100% size actually.
    QFileIconProvider is to be considered broken on windows for now (6.1.0 or below) in Qt6. There is a critical priority ticket opened against it and it’s being worked on

  • @VRonin Nice, thanks for the information. Is there a platform independent alternative or should I switch development to 5.15 for now?

  • Is there a platform independent alternative

    See https://forum.qt.io/topic/125967/possible-qt-6-03-bug

    should I switch development to 5.15 for now?

    My personal opinion expressed here: https://forum.qt.io/topic/126005/qt-6-version-readiness-for-using-when

Log in to reply