Index: window_QT.cpp =================================================================== --- window_QT.cpp (revision 1) +++ window_QT.cpp (working copy) @@ -56,6 +56,9 @@ //that is also the number of pixel per grid static CvWinProperties* global_control_panel = NULL; + +static bool externalQAppExists = false; // whether there already exists an "outside" qApp + //end static and global @@ -438,7 +441,13 @@ // check initialization status if( !wasInitialized) { - new QApplication(*c,v); + // check if another "parent" app has already + // created an app object... + if (!QApplication::instance()) { + new QApplication(*c,v); + } else { + externalQAppExists = true; + } wasInitialized = 1; qDebug()<<"init done"; @@ -705,7 +714,10 @@ { delete guiMainThread;//delete global_control_panel too guiMainThread = NULL; - qApp->quit(); + // only quit if we created the QApp ourselves... + if (!externalQAppExists) { + qApp->quit(); + } } } @@ -974,6 +986,9 @@ if (multiThreads) { + // WARNING: this could even close windows from an external parent app + //#TODO check externalQAppExists and in case it does, close windows carefully, + // i.e. apply the className-check from below... qApp->closeAllWindows(); }else{