[PySide2] Destroying the QApplication instance and creating another one gives an error
-
wrote on 7 Jan 2020, 10:10 last edited by
Hello I have a simple app which creates an application, destroys it and then creates another application again.
It works with PyQt5, but fails with PySide2, giving "RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance.". But I am already destroying the QApplication instance, or at least I think I am destroying it via "del app":
import sys from PySide2.QtWidgets import * app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() del app app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() sys.exit()
What might be the problem?
-
Hello I have a simple app which creates an application, destroys it and then creates another application again.
It works with PyQt5, but fails with PySide2, giving "RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance.". But I am already destroying the QApplication instance, or at least I think I am destroying it via "del app":
import sys from PySide2.QtWidgets import * app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() del app app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() sys.exit()
What might be the problem?
wrote on 7 Jan 2020, 11:17 last edited by@canol
You should perhaps coordinate this question with https://forum.qt.io/topic/110418/how-to-destroy-a-singleton-and-then-create-a-new-one, which seems to be the same on-going question.From what I have seen
del app
should work, but you say it does not from PySide2. If so, good luck, because I haven't come across a different answer for PySide2.... -
wrote on 7 Jan 2020, 16:20 last edited by
Closing this thread so that we can continue from the other thread, thanks for the input.
1/3