Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

workerscript always recieve the first version of ListModel



  • Peculiar behavior: I have set a timer to send a message [model] to workerscript where it would do some work but on model update, changes are not reflected in the workerscript where it only recieves the initial version on every trigger.

    // workerscript
    WorkerScript.onMessage = function (arg) {
        console.log(arg.model.get(0).next)  //it is always the initial value of model
    
    }
    
    // Main.qml
    
    import "model"
    
      DataModel {
            id: dataModel
        }
    
      WorkerScript {
            id: bgScript
            source: "script.js"
        }
      Timer {
            interval: 6000
            running: true
            repeat: true
            onTriggered: {
                console.log(dataModel.get(0).next)   // it is updated here on change
                bgScript.sendMessage({'model': dataModel})
            }
        }
    
    

Log in to reply