Skip to content

Commit ab905c8

Browse files
authored
Adjust high DPI scaling handling for Qt 6 to avoid deprecation warning (#116)
1 parent fa7defc commit ab905c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rendercanvas/qt.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def enable_hidpi():
159159
except Exception:
160160
pass # fail on non-windows
161161
try:
162-
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
162+
# https://doc.qt.io/qtforpython-6/faq/porting_from2.html#class-function-deprecations
163+
# > High DPI is by default enabled in Qt 6 and cannot be turned off.
164+
dpi_scaling_not_deprecated = qt_version_info[0] < 6
165+
if dpi_scaling_not_deprecated:
166+
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
163167
except Exception:
164168
pass # fail on older Qt's
165169

0 commit comments

Comments
 (0)