8000 qt: Avoid setting Qt5 attributes on Qt6 · matplotlib/matplotlib@6488491 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6488491

Browse files
committed
qt: Avoid setting Qt5 attributes on Qt6
In some versions, this appears to emit a deprecation warning, so don't even attempt it.
1 parent a09ddb8 commit 6488491

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/matplotlib/backends/backend_qt.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ def _create_qApp():
106106
# of Qt is not instantiated in the process
107107
if QT_API in {'PyQt6', 'PySide6'}:
108108
other_bindings = ('PyQt5', 'PySide2')
109+
qt_version = 6
109110
elif QT_API in {'PyQt5', 'PySide2'}:
110111
other_bindings = ('PyQt6', 'PySide6')
112+
qt_version = 5
111113
else:
112114
raise RuntimeError("Should never be here")
113115

@@ -123,11 +125,11 @@ def _create_qApp():
123125
'versions may not work as expected.'
124126
)
125127
break
126-
try:
127-
QtWidgets.QApplication.setAttribute(
128-
QtCore.Qt.AA_EnableHighDpiScaling)
129-
except AttributeError: # Only for Qt>=5.6, <6.
130-
pass
128+
if qt_version == 5:
129+
try:
130+
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
131+
except AttributeError: # Only for Qt>=5.6, <6.
132+
pass
131133
try:
132134
QtWidgets.QApplication.setHighDpiScaleFactorRoundingPolicy(
133135
QtCore.Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
@@ -141,10 +143,8 @@ def _create_qApp():
141143
app.lastWindowClosed.connect(app.quit)
142144
cbook._setup_new_guiapp()
143145

144-
try:
145-
app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) # Only for Qt<6.
146-
except AttributeError:
147-
pass
146+
if qt_version == 5:
147+
app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
148148

149149
return app
150150

0 commit comments

Comments
 (0)
0