Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit6488491

Browse files
committed
qt: Avoid setting Qt5 attributes on Qt6
In some versions, this appears to emit a deprecation warning, so don'teven attempt it.
1 parenta09ddb8 commit6488491

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
ifQT_APIin {'PyQt6','PySide6'}:
108108
other_bindings= ('PyQt5','PySide2')
109+
qt_version=6
109110
elifQT_APIin {'PyQt5','PySide2'}:
110111
other_bindings= ('PyQt6','PySide6')
112+
qt_version=5
111113
else:
112114
raiseRuntimeError("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-
exceptAttributeError:# Only for Qt>=5.6, <6.
130-
pass
128+
ifqt_version==5:
129+
try:
130+
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
131+
exceptAttributeError:# 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-
exceptAttributeError:
147-
pass
146+
ifqt_version==5:
147+
app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
148148

149149
returnapp
150150

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp