Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Catching 'FocusOut' or 'MouseButtonPress' from a modal dialog
comgate3 last edited by
what I am trying to do is to close a modal dialog (a dialog opened by calling 'exec()') by click/touch outside of the dialog area. (it's like..'cancel' actions u can see in mobile applications. in order to 'cancel' or 'go back', u touch the shaded area.)
say I have...a MainWindow instance and a button to popup a modal dialog.
I place 'eventFilter' to 'mainwindow', 'modal dialog', and even 'QApplication' instance. but none actually catches FocusOut or MouseButtonPress event.
QApplication eventFilter was able to catch FocusOut event when I click another application while the modal dialog is up, but that's not what I am trying to do. I need to catch FocusOut/MouseButtonPress when I click anywhere within my application, except the inside of the modal dialog.
I thought catching events in QApplication instance might catch 'MouseButtonPress' event since it's the top level QObject, but it didn't. It seems the modal dialog is raised above the application instance when it is up, and all events are blocked to every other widgets and even qapplication instance except the modal dialog.
Am I correct? and if anyone know a solution to my problem, please help me out. Please.