title: How can I change the modality of QDialog at runtime?
body: <p>I have a QDialog and I read a lot about the differences of show(), exec() and open(). Unfortunately I never found a solved solution to change the modality of a dialog at runtime. 
  I have an application and from there my QDialog is started. I have a toggle button in this dialog and with clicking on it the QDialog should change the modality,so that it is possible to interact with the application - but this shouldn't happen all the time - just when the toggle button is checked. </p>
  
  <p>Is there a possibility? I could not solve the problem with setting setModal(true/false) this just allows me to start it modal, toggle the button and set it to non modal, but then I can't go back to modal. </p>
  
  <p>Here some code:</p>
  
  <p>Starting the dialog:</p>
  
  <p>from the main window:</p>
  
  <pre><code>_dialog = new ToggleModalDialog(this, id, this);
  _dialog-&gt;setWindowModality(Qt::ApplicationModal);
  _dialog-&gt;open();
  </code></pre>
  
  <p>and here in the toggled slot in the ToggleModalDialog</p>
  
  <pre><code>void ToggleModalDialog::changeModality(bool checkState)
  {
      if(checkState)
      {
          this-&gt;setWindowModality(Qt::NonModal);
          ui-&gt;changeModalityButton-&gt;setChecked(true);
          this-&gt;setModal(false);
      }
      else
      {
          this-&gt;setWindowModality(Qt::ApplicationModal);
          ui-&gt;changeModalityButton-&gt;setChecked(true);
      }
  </code></pre>
  
  <p>Thanks in advance!</p>