title: How to set QML properties from C++
body: <p>I'm trying to do a simple task as changing a property (text: ) of some QML object from C++ yet I'm failing miserably. Any help appreciated.</p>
  
  <p>I'm not getting any errors, the window shows up, just the text property doesn't change as (at least I think) it should. 
  Is even anything I'm NOT doing wrong here?!!</p>
  
  <p>What I was trying is this:</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;QGuiApplication&gt;
  #include &lt;QQmlApplicationEngine&gt;
  #include &lt;QQuickView&gt;
  #include &lt;QQuickItem&gt;
  #include &lt;QQmlEngine&gt;
  #include &lt;QQmlComponent&gt;
  #include &lt;QString&gt;
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
  
      QQmlApplicationEngine engine;
  
  
      QQmlComponent component(&amp;engine, QUrl::fromLocalFile("main.qml"));
      QObject *object = component.create();
  
       engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
      QString thisString = "Dr. Perry Cox";
  
      object-&gt;setProperty("text", thisString);  //&lt;--- tried  instead of thisString putting "Dr. ..." but nope.
      delete object;
  
  
  
      return app.exec();
  }
  </code></pre>
  
  <p><strong>main.qml</strong></p>
  
  <pre><code>import QtQuick 2.2
  import QtQuick.Window 2.1
  
  Window {
      visible: true
      width: 360
      height: 360
  
      MouseArea {
          anchors.fill: parent
          onClicked: {
              Qt.quit();
          }
      }
  
      Text {
          id: whot
          text: ""
          anchors.centerIn: parent
          font.pixelSize: 20
          color: "green"
      }
  }
  </code></pre>