Skip to content

Commit d07618a

Browse files
Set some Qt settings to play nicer on High DPI displays
`labscript_utils.splash` is the first place a `QApplication` gets created for all of our apps. So setting these settings there applies them to all our applications, although they are also needed for the splash screen itself to be scaled better on High DPI displays. `AA_EnableHighDpiScaling` scales all pixel metrics to the device pixel ratio - so this means curved edges and padding and whatnot get scaled up, as well as the size of some pixmaps. `AA_UseHighDpiPixmaps` means to use high DPI pixmaps for icons etc, directly, rather than rendering them at the lower resolution and then scaling them up (not sure why anyone would want the latter behaviour). Strangely, high resolution pixmaps *are* used when `AA_EnableHighDpiScaling` is *off*. It's only when it is turned on that they get downscaled and then upscaled again and end up blocky.
1 parent c38b661 commit d07618a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

labscript_utils/splash.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
Qt = QtCore.Qt
3030

3131

32+
# Set auto high-DPI scaling - this ensures pixel metrics are scaled
33+
# appropriately so that we don't get a weird mix of large fonts and small
34+
# everything else on High DPI displays:
35+
QtWidgets.QApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True)
36+
# Use high res pixmaps if available, instead of rendering at low resolution and
37+
# upscaling:
38+
QtWidgets.QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
39+
40+
3241
class Splash(QtWidgets.QFrame):
3342
w = 250
3443
h = 230

0 commit comments

Comments
 (0)