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

Skip to content

Commit 89edd73

Browse files
committed
Check for already running QApplication in Qt embedding example.
1 parent 9faf231 commit 89edd73

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)