title: How can I access my Window object properties from C++ while using QQmlApplicationEngine?
body: <p>I've been trying to learn QtQuick for GUI creation, but I've been having a hard time understanding how to interact with QML objects from the C++ part of my test program.</p>
  
  <p>Here's my simple QML file:</p>
  
  <pre><code>import QtQuick 2.2
  import QtQuick.Window 2.1
  
  Window {
      id: mainWindow
      visible: true
      width: 800
      height: 800
      color: "#FFFF0000"
  
      MouseArea {
          anchors.fill: parent
          onClicked: Qt.quit()
      }
  
      Rectangle {
          id: testRect
          width: 100
          height: 100
          anchors.centerIn: parent
          color: "#FF0000FF"
      }
  }
  </code></pre>
  
  <p>Here's the basic C++ file that came with it (auto-generated by QtCreator):</p>
  
  <pre><code>#include &lt;QGuiApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
  
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
  
      return app.exec();
  }
  </code></pre>
  
  <p>My issue is that I have <em>no idea</em> how to gain access to my 'Window' QML object, and as a result, I'm unable to alter any of its properties or the properties of its children! This part of the QtQuick documentation shows two methods of accessing QML objects from within C++ code, but neither of them seem to apply to this 'QQmlApplicationEngine' loading scheme.. I've also seen people use things like 'QApplicationViewer' and 'QDeclaritiveView', but I can't seem to find those in the <em>official documentation</em> at all..</p>
  
  <p>I'm getting really frustrated with QtQuick; the 'simplicity' of QML seems to be lost in a sea of conflicting documentation and convoluted interface between C++ and QML. Is there anyway for me to access my QML objects while using the QQmlApplicationEngine method? I've tried using 'QuickView', but it doesn't seem to work well with Window QML objects..? Is QQmlApplicationEngine only useful for QML-only applications in a single file? So far, every piece of documentation and tutorial I've read has shown something different..</p>
  
  <p>Any help or clarification would be appreciated. <strong>Ideally I'd like to know how to access and modify QML objects (like 'mainWindow', 'testRect', and other objects in other files) via my C++ code.</strong></p>