title: How to change the transient parent of a QML Dialog/Window?
body: <p>I'm working on a Qt (5.3) desktop application (C++ core with a QML ui) whose main window is an <code>ApplicationWindow</code> and that at some point launches <code>Dialog</code>s.
  Since there are differences in the use of dialog modality between Windows and Mac OS X (e. g. An about dialog is rarely modal on Mac OS X but is almost always modal on Windows) and also in the way of presenting some dialogs’ content, I’ve changed the design to allow the implementation of platform specific versions of the dialogs.</p>
  
  <p>For so I created the following <strong>DialogLoader</strong>:</p>
  
  <pre><code>Loader {
      id: dialogFactory
      property string dialogName
      function platformFolder() {
          if (Qt.platform.os === "osx")
              return "osx"
          return "win"
      }
      onDialogNameChanged: { source = platformFolder() + "/" + dialogName + ".qml" }
      onStatusChanged: {
          if (dialogFactory.status === Loader.Error)
              console.log("DialogFactory: failed to load file: " + source);
          else if (dialogFactory.status === Loader.Ready)
              console.log("DialogFactory: file \"" + source + "\" loaded")
      }
  }
  </code></pre>
  
  <p>Which I use as follows:</p>
  
  <pre><code>ApplicationWindow {
      // …
      property alias aboutDialog: aboutDialogLoader.item
      // …
      DialogLoader { id: aboutDialogLoader; dialogName: "AboutDialog" }
      // …
      Action { text: qsTr("About..."); onTriggered: aboutDialog.show() }
      // …
  }
  </code></pre>
  
  <p>That approach is working fine and it suits my needs except for one thing:
  Modal dialogs on Windows don’t behave as they do when I declare them in the <code>ApplicationWindow</code> directly. If the app looses focus when a modal windows is opened and the focus is granted again, the modal window appears behind the main window which causes the app to be inoperative.</p>
  
  <p>After some research I’ve realized that the cause of the problem is that with the loader approach the <code>ApplicationWindow</code> is not acting as the transient parent of the <code>Dialog</code>.</p>
  
  <p>I've found a work-around for this by manually bringing the Dialog to front when that happens:</p>
  
  <pre><code>MainWindow {
      // ...
      onActiveChanged: {
          if (Qt.platform.os === "windows") {
              if (active) {
                  // ...
                  if (aboutDialog.visible) {
                      aboutDialog.requestActivate()
                  }
                  // ...
              }
          }
      }
      // ...
  }
  </code></pre>
  
  <p>but I think it would be better to avoid such work-arounds, if possible. After digging into the Qt documentation without any luck, I decided to post this question, which can be resumed as follows:
  Is it possible to change the transient parent of a QML Window? If so, please would you point out how?</p>
  
  <p>Suggestions about a different approach that could avoid the reparent stuff are welcome.</p>