[Qt-qml] Object passing in threaded applications.

René Hansen ext-rene.1.hansen at nokia.com
Wed Nov 10 13:49:56 CET 2010


I've run my head against the wall with this. Consider the following
example:

main.qml:

import Qt 4.7
Rectangle {
        ListModel {
                id:lm
        }
        Rectangle {
                id:rect
        }
        QtObject {
                id:qtob
        }
        Custom {
                id:custom
        }
        WorkerScript {
                id:testworker
                source: "../../../Threading/worker.js"
        }
        Component.onCompleted: {
                testworker.sendMessage({'object': lm})
                testworker.sendMessage({'object': rect})
                testworker.sendMessage({'object': qtob})
                testworker.sendMessage({'object': custom})
        }
}


worker.js:

WorkerScript.onMessage = function(msg) {
        console.log("object passed: " + msg.object)
}


Custom.qml:

import Qt 4.7
Rectangle {
        width: 640
        height: 480
}

What this outputs is this:

object passed: QDeclarativeListModelWorkerAgent(name = "")

object passed: null

object passed: null

object passed: null




And my question is then, is there any other QML objects besides
ListModel I can use? Where can I find the documentation? Why isn't there
support of custom objects?

/René




More information about the Qt-qml mailing list