setWindowModality problem!!!



  • i use setWindowModality to dynamically change a QDockWidget's modality.
    but i met a problem!

    void MyDockWidget::closeEvent(QCloseEvent* event)
    {
    if (windowModality() == Qt::ApplicationModal)  //WindowModality also failed...
      setWindowModality(Qt::NonModal);
    
    QDockWidget::closeEvent(event);
    }
    

    here i want to reset it back to non-modal....but after i close the modal one....the whole Qt app including the MainWindow and other windows Cannot clicked....the whole app seems be Frozen....i don;t know why...



  • it seems like the Mainwindow and other windows still keep the state while the QDockWidget is modal......frozen there...cannot click anywhere...
    and i tried to setFocus to the Mainwindow...still not worked....



  • anyone know met this problem?



  • As far as I understand modality should not be changed after widget is shown,
    It is not simply a state, it is much more.
    Question is why do you want to do it.
    Mostly likely you should change the design to avoid this.
    But here is what documentation says:
    "Changing this property while the window is visible has no effect; you must hide() the widget first, then show() it again."


Log in to reply
 

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