title: Make QDialog modal to operating system
body: <p>Is it possible that if a <code>QDialog</code> instance is <code>exec()</code>uted, the entire operating system is blocked until the user closes the dialog? In the following minimal example the dialog blocks only its parent widget but not the OS elements outside of the Qt application.</p>
  
  <p>rootwindow.h</p>
  
  <pre><code>#ifndef ROOTWINDOW_H
  #define ROOTWINDOW_H
  
  #include &lt;QApplication&gt;
  #include &lt;QMainWindow&gt;
  #include &lt;QtDebug&gt;
  #include &lt;QDialog&gt;
  #include &lt;QPushButton&gt;
  #include &lt;QMessageBox&gt;
  #include &lt;QBoxLayout&gt;
  
  class RootWindow : public QMainWindow
  {
      Q_OBJECT
  
  private:
  
      QWidget *widgetCentral;
      QBoxLayout *layoutMain;
      QPushButton *button;
      QDialog *dialog;
  
  public:
  
      RootWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
      ~RootWindow();
  
  private slots:
  
      void slotClicked();
  };
  
  #endif // ROOTWINDOW_H
  </code></pre>
  
  <p>rootwindow.cpp</p>
  
  <pre><code>#include "rootwindow.h"
  
  RootWindow::RootWindow(QWidget *parent, Qt::WindowFlags flags): QMainWindow(parent, flags)
  {
      setCentralWidget( widgetCentral = new QWidget );
      widgetCentral-&gt;setLayout( layoutMain = new QBoxLayout(QBoxLayout::LeftToRight) );
      layoutMain-&gt;addWidget(button = new QPushButton("Click me"));
  
      dialog = new QDialog(this);
      dialog-&gt;setModal(true);
      dialog-&gt;setWindowModality(Qt::ApplicationModal);
  
      connect(button, &amp;QPushButton::clicked, this, &amp;RootWindow::slotClicked);
  }
  
  RootWindow::~RootWindow()
  {
  
  }
  
  void RootWindow::slotClicked()
  {
      int i = dialog-&gt;exec();
      qDebug() &lt;&lt; "Dialog result: " &lt;&lt; i;
  }
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include "rootwindow.h"
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
  
      RootWindow w;
      w.show();
  
      return a.exec();
  }
  </code></pre>