Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.6.1
-
None
-
Windows 7 64 bits
-
Fix Win theme: 6bb0bc73c809d1defdcedc31c4c464a129d3de4d (qtbase/5.6, 14.7.2016, 5.6.2)
Description
A menu is populated dynamically for offering a recent file list. Qt 5.6.1 does not resize properly the icons, they appear cropped. Qt 5.4.2 displays the icons properly.
Static menus with icons (built from Qt Designer) do not suffer from this bug.
The icons which were retrieved by QFileIconProvider have been investigated (sizes were listed and every pixmap saved to a PNG) and are not in cause.
Here is a MCVE:
#include <QApplication> #include <QMainWindow> #include <QFileIconProvider> #include <QMenuBar> #include <QIcon> int main(int argc, char *argv[]) { QApplication a(argc, argv); QMainWindow w; QFileIconProvider iconProvider; QIcon icon = iconProvider.icon(QFileInfo("C:/Windows/explorer.exe")); w.menuBar()->addAction(new QAction(icon, "Test", w.menuBar())); w.show(); return a.exec(); }
The problem is somewhat fixed if I extract a PNG from the icon and recreate the icon:
icon = QIcon(icon.pixmap(QSize(16,16)));
icon = QIcon(icon.pixmap(QSize(32,32)));
The QIcon has sizes 16x16 and 32x32. The system DPI setting in Windows 7 and Qt takes it as a device pixel ratio of 1.25
The returned icon pixmaps are 20x20 and 40x40 but they have a devicePixelRatio of 1.0, whereas they should have 1.25
When using a DPI setting of 100% in Windows 7 the issues does not appear anymore.