Sheet dialog and Menu bar-focus issue

  • In my application ,i display a sheet dialog (using open() and setting windows modality ),when this dialog is still in the view,user is able to click on application's menu bar and click on Quit.And when the user clicks on Quit,i have a slot to display some other sheet dialog( document dirty ).Now the issue is that the second sheet dialog is displayed behind the first sheet dialog,resulting which second sheet dialog will never be visible and user cannot do ANYTHING on the first sheet dialog.So it looks like that application is frozen.
    Is there anyway in Qt ,that i can know if already a sheet dialog is displayed?
    Or even on Quit clicked, the corresponding slot should not be invoked,since another sheet dialog is still displayed?

    Also both the dialogs have same parent and i cannot use exec to display the first sheet dialog( which btw disables the Quit menu option , i cannot use exec,since it will block the event loop which i dont want )

    Is there any way out of this situation?

    I am using Qt5 on Mac OS 10.9.5

  • I am not sure what do you mean under sheet dialog.

    If it means that widget has Qt::Sheet ( Macintosh sheet), even so I am not an expert on Mac this should imply window modality.

    Thus to have normal modeless behavior you can't use it.
    Use normal QDialog (with flag Qt::Dialog) instead.

    Hope this help,

  • Thank you very much for your reply

    The flag Qt::Dialog is the default flag for QDialog,so i think it will not make any difference.Anyways,i used it and still no difference.

    Sheet dialogs are special dialogs on Mac,to achieve that I am making sure that my dialog is a modal dialog.To achieve that i call setWindowsModiality( Qt::WindowModal ) followed by show(). (as mentioned in Qt documentation ).

    Now the issue is that ,even when this dialog is modal (according to Qt documentation) still user is able to click on Quit option on the menu bar
    (On Mac this is system-wide menu bar ).

    So according to my understanding since it is modal dialog, Quit action should not be triggered.

    To me it looks like a Qt bug.

  • QApplication::activeModalWidget(),solved the issue for me

Log in to reply

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