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

QIcon::pixmap selects wrong icon file from theme

    XMLWordPrintable

Details

    • All
    • 46e7060ee (dev), 0cff18f1a (6.10)

    Description

      Creating a pixmap from a QIcon will sometimes choose the wrong icon file depending on the theme and scale. In this example with the Adwaita theme it chose the 16x16 png instead of the svg, which is much worse for the requested size and scale.

      #include <QtWidgets>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QIcon::setThemeName("Adwaita");
          QIcon icon = QIcon::fromTheme(QStringLiteral("folder-documents"));
          qDebug() << icon.availableSizes(); // QList(QSize(16, 16), QSize(128, 128))
          QPixmap pixmapRegular = icon.pixmap(QSize(128, 128), 1.0);
          qDebug() << pixmapRegular.size(); // QSize(128, 128): OK
          QPixmap pixmapScaled = icon.pixmap(QSize(128, 128), 2.0);
          qDebug() << pixmapScaled.size(); //  QSize(16, 16): wrong
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              dernett Alexander Burnett
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change