title: How do I toggle 'always on top' for a QMainWindow in Qt without causing a flicker or a flash?
body: <pre><code>void MainWindow::on_actionAlways_on_Top_triggered(bool checked)
  {
      Qt::WindowFlags flags = this-&gt;windowFlags();
      if (checked)
      {
          this-&gt;setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
          this-&gt;show();
      }
      else
      {
          this-&gt;setWindowFlags(flags ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
          this-&gt;show();
      }
  }
  </code></pre>
  
  <p>The above solution works but because setWindowFlags hides the window, it needs to be re-shown and of course that doesn't look very elegant. So how do I toggle "always on top" for a QMainWindow without that "flashing" side effect?</p>