Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-134239

QAbstractFileIconProvider::icon() always returns null on mobile platforms

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.8.2
    • GUI: Other
    • Pixel 4 API Level 31 Emulator; iOS 18.2 Simulator
    • Android, iOS/tvOS/watchOS

    Description

      Code

      #include <QtWidgets>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QWidget win;
          auto layout = new QVBoxLayout(&win);
      
          QAbstractFileIconProvider provider;
          QMap<QString, QIcon> iconMap
          {
              {"Computer", provider.icon(QAbstractFileIconProvider::Computer)},
              {"Desktop", provider.icon(QAbstractFileIconProvider::Desktop)},
              {"Trashcan", provider.icon(QAbstractFileIconProvider::Trashcan)},
              {"Network", provider.icon(QAbstractFileIconProvider::Network)},
              {"Drive", provider.icon(QAbstractFileIconProvider::Drive)},
              {"Folder", provider.icon(QAbstractFileIconProvider::Folder)},
              {"File", provider.icon(QAbstractFileIconProvider::File)},
              {"CSV File", provider.icon(QFileInfo("dummy.csv"))},
              {"JPG File", provider.icon(QFileInfo("dummy.jpg"))},
              {"PDF File", provider.icon(QFileInfo("dummy.pdf"))}
          };
      
          for (const auto& key : iconMap.keys())
          {
              auto icon = iconMap[key];
              qDebug() << key << "Icon null?:" << icon.isNull();
              layout->addWidget(new QPushButton(icon, key));
          }
      
          win.show();
          return a.exec();
      }
      
      

       

      Outcomes

      • (Windows/macOS) All icons are not null; the buttons show text + icons (Expected)
      • (Android/iOS) All icons are null; the buttons only show text (Not Expected)

       

      Notes

      Changing from QAbstractFileIconProvider to QFileIconProvider makes icon(QAbstractFileIconProvider::IconType) return icons on the mobile platforms, but this imposes a dependency on Qt Widgets. It also doesn't help icon(const QFileInfo &)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes