Is QML Guaranteed to be Processed serially?

  • I have this script:
    import QtQuick 1.0
    import FileIO 1.0
    import RectData 1.0

    Rectangle {
    id: main
    width: 360
    height: 360

    MouseArea {
        anchors.fill: parent
        onClicked: {
    FileIO {
        id: reader
        source: "./rectangles.txt"
        onError: console.log(msg)
    RectData {
        id: rectangles
     Text {
          id: mytxt
            Component.onCompleted: {
                mytxt.text =
                console.log (rectangles.populate(mytxt.text, width, height))
                mygrid.focus = true;
    GridView {
        id: mygrid
        width: 100
        height: 100
        model: rectangles
        delegate: RectDelegate

    In this QML, I want to read a txt file(C++ function rectangles.populate()) and process it before the Grid shows it. IS sequential parsing and processing guaranteed in QML? Am I implementing it correct?

  • Moderators

    QML is read first, then it's being processed in an event loop. You can't depend on that being sequential.

    But if your model is done properly, the engine will detect that "rectangles" has hanged and will be updated once the changes are done.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.