@@ -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