how to close the application when the mouse click outside the window.
in my application ,I popu a window ,and I want to close it when I click the outside this popu window or the mouse click the desktop.
how to close the application when the mouse click outside the window.
in my application ,I popu a window ,and I want to close it when I click the outside this popu window or the mouse click the desktop.
Hi,
You can do it in focusOut event.
Just call close method of your widget.
A Qt::Popup window does that automatically.
J-P Nurmi
Then try catching QEvent::WindowDeactivate.
J-P Nurmi
When the mouse is clicked anywhere inside the application window, the popup (if its a menu) should close automatically. When the mouse is clicked anywhere outside your application window, QMainWindow's WindowDeactivate event is invoked. You will need to reimplement QMainWindow's event function in your class, catch the WindowDeactivate even and check if your popup is open or not. Close (or maybe hide ) it accordingly.
Mithin
www.mithin.in
it is very eary,just use
setWindowFlags(Qt::Popup) ;
and close it at the mousePressEvent()
Bookmarks