Catching 'FocusOut' or 'MouseButtonPress' from a modal dialog



  • Hi

    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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.