Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Prevent QMdiArea's current subwindow switching



  • I have a QMdiArea with several subwindows, when the user wants to switch from one subwindow to another, I need to do some check, and may need to prevent the switching. I tried the below:

    • Capture "subWindowActivated" signal of QMdiArea, but the signal actually emited only after the switching

    • Capture the "aboutToActivate" signal of the subwindow, but in this signal I can't call "setActiveSubWindow" to force switching back to the previous window, or the application will crash.

    So, any good method to achieve my goal?


  • Lifetime Qt Champion

    Hi,

    What kind of checks are they ?
    What about doing it the other way around: keep the other subwindows disabled until the checks pass ?



  • There are some input widgets on the subwindow, when user want to switch to other subwindow, I need to validate the user inputs, if there are some wrong data, I should force the user stay on current subwindow.


  • Lifetime Qt Champion

    Then I stay by my suggestion: make your sub window "modal" so that your application users know that they have to first do things correctly before going further with their actions.



  • I finally use event filter to filter the "user click on tab" event to achieved my goal.


Log in to reply