Repository navigation
Sharp images and scaled text with Windows display scaling - #122
Merged
Merged
Conversation
Load an image as a pixmap at the resolution of the display: when the device pixel ratio is greater than 1 (display scaling greater than 100%), the high-resolution variants of the image following Qt's @nx naming convention (e.g. logo@2x.png next to logo.png) are resampled to the device resolution, so that the image remains sharp instead of being upscaled by Qt. get_image_label (and thus get_image_layout) now relies on it. Refs #121 Assisted-by: Claude Opus 5.5
With Qt 5 on Windows, the default application font is derived from the legacy DEFAULT_GUI_FONT stock object, whose pixel size ignores the display scaling, while Qt converts it to points with the DPI of the primary screen: at 125%, it ends up at 6.6pt instead of 8.25pt, so that the text of most widgets keeps its 100% size, unlike menus and status bars. qapplication() now uses the message font of the system (typically "Segoe UI", 9pt) as default font with Qt 5 on Windows, like Qt 6 does (QTBUG-58610), and restores the fonts set by the platform theme for specific widget classes, which QApplication.setFont clears. Closes #121 Assisted-by: Claude Opus 5.5
This was referenced Oct 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #121 (related: DataLab-Platform/DataLab#460).
With a Windows display scaling greater than 100% (e.g. 125%), applications based on guidata showed most of their text at its 100% size (Qt 5 only) and blurry images.
Changes
get_pixmap(new feature) —guidata.configtools.get_pixmaploads an image as a pixmap at the resolution of the display: when the device pixel ratio is greater than 1, the high-resolution variants of the image following Qt's@Nxnaming convention (e.g.logo@2x.pngnext tologo.png) are resampled to the device resolution (smallest variant covering the ratio, or the largest one), so that the image remains sharp. Without variants, the image is returned as is.get_image_label(and thusget_image_layout) now relies on it.DEFAULT_GUI_FONTstock object ("MS Shell Dlg 2", 8pt), whose pixel size ignores the display scaling, while Qt converts it to points with the DPI of the primary screen: at 125%, it ends up at 6.6pt instead of 8.25pt.qapplication()now uses the message font of the system (typically "Segoe UI", 9pt) as default font, like Qt 6 does (QTBUG-58610), and restores the fonts set by the platform theme for specific widget classes (menus, status bar, item views, ...), whichQApplication.setFontclears. No change with Qt 6 or on other platforms. Note: with Qt 5 on Windows, the text is now slightly larger at 100% too (same font as with Qt 6 and native Windows applications).Tests
guidata/tests/unit/test_hidpi.py: variant selection and pixmap size/device pixel ratio for several ratios, image without variant, default ratio, default font logic (platform and binding simulated) and actual behavior with Qt 5 on Windows.--show-windowson Windows, PyQt5).