<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello all!<br>
    Is there any way to know when QML data was loaded into engine?<br>
    In my QML app I want to make a screenshot after all the source was
    loaded.<br>
    <br>
    <pre>QQmlApplicationEngine engine;
engine.loadData(data);
QQuickWindow *rootObject = qobject_cast<QQuickWindow *>(p_engine.rootObjects().first());</pre>
    <pre>QImage image = rootObject->grabWindow();
image.save("window.png","PNG",90); 


</pre>
    <pre><font face="sans-serif">where data is simple QML file:

</font><pre><tt>import QtQuick 2.3
import QtQuick.Window 2.2</tt></pre><pre><tt>Window {
    visible: true
    width: 360
    height: 360</tt></pre><pre><tt>    Text {
        anchors.centerIn: parent
        text: "Hello, world!"
    }
    MouseArea {
         anchors.fill: parent
         //onClicked: someSingleton.makeScreenshot();
    }
</tt></pre><pre><tt>}</tt></pre><font face="sans-serif">
But image not saved just because it is empty. If I call QQuickWindow::grabWindow() from QML, for example, after clicking at MouseArea it works well.

So from this I conclude that</font> <font face="sans-serif">when I call</font> rootObject->grabWindow() <font face="sans-serif">it still not loaded completly yet</font>. <font face="sans-serif">I've tried to call this function in this way:</font>

connect(rootObject,&QQuickWindow::afterRendering,[=] () {
        QImage image = rootObject->grabWindow();
        image.save("window.png","PNG",90);
});

<font face="sans-serif">But the program just hungs up in this slot and no image was saved.  </font>
</pre>
    <br>
    <br>
    <br>
    <br>
  </body>
</html>