Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Is QML Guaranteed to be Processed serially?
Qt 6.12 LTS is out! See what's new in the release blog

Is QML Guaranteed to be Processed serially?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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: {
            Qt.quit();
        }
    }
    
    FileIO {
        id: reader
        source: "./rectangles.txt"
        onError: console.log(msg)
    }
    
    RectData {
        id: rectangles
    }
    
     Text {
          id: mytxt
            text:"starting.."
            Component.onCompleted: {
                mytxt.text = reader.read()
                console.log (rectangles.populate(mytxt.text, width, height))
                mygrid.focus = true;
            }
     }
    
    GridView {
        id: mygrid
        x:0
        y:0
        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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved