diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index a1d2079743..32f82207a6 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -120,17 +120,20 @@ FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args) t.detach(); } else { + // In order to get Jupiter notebook integration working we must create a direct instance + // of QApplication. Not even a sub-class can be used because otherwise PySide2 wraps it + // with a QtCore.QCoreApplication which will raise an exception in ipykernel #if defined(Q_OS_WIN) static int argc = 0; static char **argv = {0}; - (void)new QtApplication(argc, argv); + (void)new QApplication(argc, argv); // When QApplication is constructed hhook = SetWindowsHookEx(WH_GETMESSAGE, FilterProc, 0, GetCurrentThreadId()); #elif !defined(QT_NO_GLIB) static int argc = 0; static char **argv = {0}; - (void)new QtApplication(argc, argv); + (void)new QApplication(argc, argv); #else PyErr_SetString(PyExc_RuntimeError, "Must construct a QApplication before a QPaintDevice\n"); return NULL;