diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 3746acb171..d327ad6603 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -854,14 +854,17 @@ GuiReceiver::GuiReceiver() : bTimeOut(false), nb_windows(0) void GuiReceiver::isLastWindow() { - if (--nb_windows <= 0) + if (qApp->quitOnLastWindowClosed()) { - delete guiMainThread;//delete global_control_panel too - guiMainThread = NULL; - - if (doesExternalQAppExist) + if (--nb_windows <= 0) { - qApp->quit(); + delete guiMainThread; // delete global_control_panel too + guiMainThread = NULL; + + if (doesExternalQAppExist) + { + qApp->quit(); + } } } }