From 0f89dbb571b642d354192ff274aa501d6c6e1182 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 1 Aug 2024 13:47:34 +0200 Subject: [PATCH] Windows: Use pixmaps at 1.0 scale for icons in the QPA menus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Menu type from Qt Quick's libs.platform module on Windows uses the Win32-based menus implemented in the Windows QPA backend. Those are not High-DPI aware, so we cannot use a scaled up pixmap for the menu icons. The native Windows icon engine returns scaled pixmaps (defaulting to the QGuiApplication::devicePixelRatio value if not explicitly specified), so we have to explicitly ask for pixmaps with scale factor 1.0. Pick-to: 6.7 Fixes: QTBUG-127551 Change-Id: I191915127890ae265b169d5cd8d6c9f058e36a13 Reviewed-by: Tor Arne Vestbø (cherry picked from commit fdfb360f4f60cbdb9ce7f29f424dad70f0679b17) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowsmenu.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index 79deeeaea24..bc09dc7b90e 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -235,7 +235,9 @@ void QWindowsMenuItem::updateBitmap() freeBitmap(); if (!m_icon.isNull()) { const int size = m_iconSize ? m_iconSize : GetSystemMetrics(SM_CYMENUCHECK); - m_hbitmap = qt_pixmapToWinHBITMAP(m_icon.pixmap(QSize(size, size)), 1); + // native Win32 menus don't support high-DPI versions of icons, so always + // use the pixmap for a 1.0 scale factor. + m_hbitmap = qt_pixmapToWinHBITMAP(m_icon.pixmap(QSize(size, size), 1.0), 1); } MENUITEMINFO itemInfo; menuItemInfoInit(itemInfo);