Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 24e4bea

Browse files
authored
Merge pull request #13731 from anntzer/qt-check-qapp
Check for already running QApplication in Qt embedding example.
2 parents f80eb08 + 89edd73 commit 24e4bea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/user_interfaces/embedding_in_qt_sgskip.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def _update_canvas(self):
5858

5959

6060
if __name__ == "__main__":
61-
qapp = QtWidgets.QApplication(sys.argv)
61+
# Check whether there is already a running QApplication (e.g., if running
62+
# from an IDE).
63+
qapp = QtWidgets.QApplication.instance()
64+
if not qapp:
65+
qapp = QtWidgets.QApplication(sys.argv)
66+
6267
app = ApplicationWindow()
6368
app.show()
6469
qapp.exec_()

0 commit comments

Comments
 (0)