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

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

    XMLWordPrintable

Details

    • Android, iOS/tvOS/watchOS, Linux/Wayland
    • 560bf5a07 (dev), 4a4d11c17 (6.10), 563f2273f (dev), f036bd0ed (dev), 8d795f529 (6.10), 5cf2a29fd (dev), ae4e6bd4c (dev), 7c574a09b (6.10)

    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

          For Gerrit Dashboard: QTBUG-134239
          # Subject Branch Project Status CR V

          Activity

            People

              vhilshei Volker Hilsheimer
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: