-
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? -
Hi
You mean the windows text scale ?
Icon did show using Qt 5.15.1
using your code. ( also at 125% etc) -
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