Issue
I am migrating (someone else his) code from pyqt5 to pyqt6 and the following code is giving me an error:
def quitApp(self):
""" Exit application callback """
QtWidgets.qApp.quit
It seems that this no longer works in pyqt6 (I get the error in the title). I tried to find how I am supposed to do this in pyqt6 but I could not find it, unfortunately.
Anyone any ideas?
Solution
QtWidgets.qApp
is appication instance, to obtain application instance in pyqt6
you can call QtWidgets.QApplication.instance()
method, but it's not necessary since all instance methods exposed in QtWidgets.QApplication
as static methods (QtWidgets.QApplication
implements singleton pattern), so to quit you can call QtWidgets.QApplication.quit()
which does the same as QtWidgets.QApplication.instance().quit()
does.
This works in pyqt6
and in pyqt5
.
Answered By - mugiseyebrows
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.