@@ -125,7 +125,6 @@ def _isdeleted(obj):
125125 (_setup_pyqt5plus , QT_API_PYQT5 ),
126126 (_setup_pyqt5plus , QT_API_PYSIDE2 ),
127127 ]
128-
129128 for _setup , QT_API in _candidates :
130129 try :
131130 _setup ()
@@ -138,13 +137,21 @@ def _isdeleted(obj):
138137 .format (", " .join (_ETS .values ())))
139138else : # We should not get there.
140139 raise AssertionError (f"Unexpected QT_API: { QT_API } " )
140+ _version_info = tuple (QtCore .QLibraryInfo .version ().segments ())
141+
142+
143+ if _version_info < (5 , 10 ):
144+ raise ImportError (
145+ f"The Qt version imported is "
146+ f"{ QtCore .QLibraryInfo .version ().toString ()} but Matplotlib requires "
147+ f"Qt>=5.10" )
141148
142149
143150# Fixes issues with Big Sur
144151# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
145152if (sys .platform == 'darwin' and
146153 parse_version (platform .mac_ver ()[0 ]) >= parse_version ("10.16" ) and
147- QtCore . QLibraryInfo . version (). segments () <= [ 5 , 15 , 2 ] ):
154+ _version_info < ( 5 , 15 , 2 ) ):
148155 os .environ .setdefault ("QT_MAC_WANTS_LAYER" , "1" )
149156
150157
@@ -167,36 +174,6 @@ def _exec(obj):
167174 obj .exec () if hasattr (obj , "exec" ) else obj .exec_ ()
168175
169176
170- def _devicePixelRatioF (obj ):
171- """
172- Return obj.devicePixelRatioF() with graceful fallback for older Qt.
173-
174- This can be replaced by the direct call when we require Qt>=5.6.
175- """
176- try :
177- # Not available on Qt<5.6
178- return obj .devicePixelRatioF () or 1
179- except AttributeError :
180- pass
181- try :
182- # Not available on older Qt5.
183- # self.devicePixelRatio() returns 0 in rare cases
184- return obj .devicePixelRatio () or 1
185- except AttributeError :
186- return 1
187-
188-
189- def _setDevicePixelRatio (obj , val ):
190- """
191- Call obj.setDevicePixelRatio(val) with graceful fallback for older Qt.
192-
193- This can be replaced by the direct call when we require Qt>=5.6.
194- """
195- if hasattr (obj , 'setDevicePixelRatio' ):
196- # Not available on older Qt5.
197- obj .setDevicePixelRatio (val )
198-
199-
200177@contextlib .contextmanager
201178def _maybe_allow_interrupt (qapp ):
202179 """
0 commit comments