title: QML function invoked from C++ not able to update element
body: <p>I am invoking a QML function from C++. Issue is the QML function cannot update a QML element when invoked from C++. below is code:</p>
  
  <p>In <code>main.qml</code>:</p>
  
  <pre><code>import QtQuick 2.0
  
  function myQmlFunction(msg) {
      console.log("Got message:", msg)
      textbox.text = msg
      return "some return value"
  }
  
  Text {
      id: textbox
      text: "nothing"
  }
  </code></pre>
  
  <p>In <code>main.cpp</code>:</p>
  
  <pre><code>QQmlEngine engine;
  QQmlComponent component(&amp;engine, "MyItem.qml");
  QObject *object = component.create();
  
  QVariant returnedValue;
  QVariant msg = "Hello from C++";
  QMetaObject::invokeMethod(object, "myQmlFunction",
      Q_RETURN_ARG(QVariant, returnedValue),
      Q_ARG(QVariant, msg));
  
  qDebug() &lt;&lt; "QML function returned:" &lt;&lt; returnedValue.toString();
  delete object;
  </code></pre>
  
  <p>The textbox element is just a regular text, and the text inside it remains "nothing", instead of the expected "Hello from C++".</p>
  
  <p>Any ideas on how to solve this issue or in successfully passing arguments from C++ to QML?</p>