Repository navigation
Qt preview and qtvcp: follow the display scale on HiDPI #4871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f54ce96
f0a64f7
fc6e7c0
8f123eb
9df60bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,6 +110,21 @@ def __init__(self): | |
| # so web engine can load local images | ||
| sys.argv.append("--disable-web-security") | ||
|
|
||
| # Qt5 leaves high-DPI scaling off: on a scaled display the fonts | ||
| # follow the screen DPI while widget sizes stay in raw pixels, so | ||
| # text outgrows its widgets. Qt6 always scales and has no switch. | ||
| import qtpy | ||
| if qtpy.QT5: | ||
| QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling) | ||
| QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Qt5 rounds the scale factor to the nearest integer, so a 150% desktop becomes 2x and a 1920x1080 screen looks like 960x540 to qtvcp. Adding
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 9df60bb, inside the Qt5 block and guarded for Qt older than 5.14. I could not reproduce the 150% rounding on my machine, so I have only confirmed that PyQt5 5.15 accepts the call. |
||
| # Qt5 rounds the factor to an integer (150% becomes 2x); pass | ||
| # it through unrounded as Qt6 does. Needs Qt 5.14. | ||
| try: | ||
| QtGui.QGuiApplication.setHighDpiScaleFactorRoundingPolicy( | ||
| QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough) | ||
| except AttributeError: | ||
| pass | ||
|
|
||
| # initialize QApp so we can pop up dialogs now. | ||
| global APP | ||
| APP = MyApplication(sys.argv) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qtvcp's
GCodeGraphicsoverridesselect_firein lib/python/qtvcp/widgets/gcode_graphics.py and still callsself.select(x, y), so qtdragon and qtaxis don't get this scaling. At 200% clicking a program line selects nothing in qtdragon; with the scaling in the override it works. Could the override get it too, or call this one after its own checks?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed in fc6e7c0: the override in gcode_graphics.py now scales the position the same way. I have not clicked through it in qtdragon myself yet, so a check on your side would be welcome.