diff --git a/modules/highgui/doc/qt_new_functions.rst b/modules/highgui/doc/qt_new_functions.rst index cf079c4e84..bb85ec4d33 100644 --- a/modules/highgui/doc/qt_new_functions.rst +++ b/modules/highgui/doc/qt_new_functions.rst @@ -4,7 +4,7 @@ Qt New Functions .. image:: pics/qtgui.png -This figure explains new functionality implemented with Qt* GUI. The new GUI provides a statusbar, a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it. +This figure explains new functionality implemented with Qt* GUI. The new GUI provides a statusbar, a toolbar, and a control panel. The control panel can have trackbars and buttonbars attached to it. If you can't see the control panel then press Ctrl+P or right-click on any Qt-window and select "Display properties window". * To attach a trackbar, the window name parameter must be NULL. diff --git a/modules/highgui/doc/user_interface.rst b/modules/highgui/doc/user_interface.rst index 8d345969f1..745fdaa3dd 100644 --- a/modules/highgui/doc/user_interface.rst +++ b/modules/highgui/doc/user_interface.rst @@ -104,6 +104,8 @@ The function ``namedWindow`` creates a window that can be used as a placeholder If a window with the same name already exists, the function does nothing. +You can call :cpp:func:`destroyWindow` or :cpp:func:`destroyAllWindows` to close the window and de-allocate any associated memory usage. For a simple program, you do not really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit. + **[Qt Backend Only]** Qt-specific details: @@ -126,6 +128,35 @@ Qt-specific details: .. + +.. index:: destroyWindow + +.. _destroyWindow: + +destroyWindow +------------- +.. ocv:function:: void destroyWindow( const string &winname ) + + Destroys a window. + + :param winname: Name of the window to be destroyed. + +The function ``destroyWindow`` destroys the window with the given name. + + +.. index:: destroyAllWindows + +.. _destroyAllWindows: + +destroyAllWindows +----------------- +.. ocv:function:: void destroyAllWindows() + + Destroys all of the HighGUI windows. + +The function ``destroyAllWindows`` destroys all of the opened HighGUI windows. + + .. index:: setTrackbarPos .. _setTrackbarPos: diff --git a/modules/highgui/include/opencv2/highgui/highgui.hpp b/modules/highgui/include/opencv2/highgui/highgui.hpp index 205476f8a4..094aeda25f 100644 --- a/modules/highgui/include/opencv2/highgui/highgui.hpp +++ b/modules/highgui/include/opencv2/highgui/highgui.hpp @@ -58,6 +58,7 @@ enum { WINDOW_AUTOSIZE=1 }; CV_EXPORTS_W void namedWindow( const string& winname, int flags=WINDOW_AUTOSIZE ); CV_EXPORTS_W void destroyWindow( const string& winname ); +CV_EXPORTS_W void destroyAllWindows(); CV_EXPORTS_W int startWindowThread(); CV_EXPORTS_W void setWindowProperty(const string& winname, int prop_id, double prop_value);//YV diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index c9b054a419..b6aca7d3cc 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -136,6 +136,11 @@ void cv::destroyWindow( const string& winname ) cvDestroyWindow( winname.c_str() ); } +void cv::destroyAllWindows() +{ + cvDestroyAllWindows(); +} + void cv::setWindowProperty(const string& winname, int prop_id, double prop_value) { cvSetWindowProperty( winname.c_str(),prop_id,prop_value); diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index d97928c505..65b50b6966 100755 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -1338,8 +1338,11 @@ void CvButtonbar::addButton( QString name, CvButtonCallback call, void* userdata } if (button) - { - QObject::connect( button, SIGNAL( toggled(bool) ),button, SLOT( callCallBack(bool) )); + { + if (button_type == CV_PUSH_BUTTON) + QObject::connect( button, SIGNAL( clicked(bool) ),button, SLOT( callCallBack(bool) )); + else + QObject::connect( button, SIGNAL( toggled(bool) ),button, SLOT( callCallBack(bool) )); addWidget(button,Qt::AlignCenter); } }