Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Qt 6.0.3 QFileIconProvider and High DPI
QtWS25 Last Chance

Qt 6.0.3 QFileIconProvider and High DPI

Scheduled Pinned Locked Moved Solved Qt 6
6 Posts 3 Posters 742 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leoklaus
    wrote on last edited by leoklaus
    #1

    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;
        ui->pushButton->setIcon(icon);
    }
    

    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?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi

      You mean the windows text scale ?
      alt text

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

      L 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi

        You mean the windows text scale ?
        alt text

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

        L Offline
        L Offline
        leoklaus
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #4

          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

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          L 1 Reply Last reply
          1
          • VRoninV VRonin

            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

            L Offline
            L Offline
            leoklaus
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              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

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved