×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    2

    Issue with dynamic data and WorkerScript

    I have an issue with that my WorkerScript does not reach updated data in a ListModel.

    Code:
    ListModel {
            id: listModel
            ListElement{title:"test"}
        }
    
        Timer {
            repeat: true; interval: 2000; running: true
            onTriggered: {
                listModel.setProperty(0, "title", listModel.get(0).title+"!")
                console.log("Title outside: "+listModel.get(0).title)
                worker.sendMessage({'model': listModel});
            }
        }
    
        WorkerScript {
            id: worker
            source: "worker.js"
        }
    The code above updates the title property on the first element in the model by adding a "!" to the title.

    By worker.js contains:
    Code:
    .pragma library
    
    WorkerScript.onMessage = function(msg) {
        console.log("Title in script: "+msg.model.get(0).title)
    }
    but if run this code the console shows:
    Code:
    Title outside: test!
    Title in script: test!
    Title outside: test!!
    Title in script: test!
    Title outside: test!!!
    Title in script: test!
    Title outside: test!!!!
    Title in script: test!
    It looks like the updated model is not reached by the script. What is the correct way to do this?

  2. #2
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Issue with dynamic data and WorkerScript

    Where is List View ?

    Check this example : http://doc.qt.nokia.com/4.7-snapshot...h-workerscript

    regards,
    rahul

  3. #3
    Registered User
    Join Date
    Oct 2011
    Posts
    2

    Re: Issue with dynamic data and WorkerScript

    I didn't expect the ListView to matter in this case, is handling the model that is the issue.

    The Model is however:

    Code:
        ListView {
            anchors.fill: parent
            model: listModel
            delegate:
                Text {
                    anchors.centerIn: parent
                    text: qsTr(""+title)
                    color: platformStyle.colorNormalLight
                    font.pixelSize: 20
                }
    
        }
    Please test the code above and see if it works for you. It a very simplified example just to trigger the behavior that i find in a bigger application.

Similar Threads

  1. How is the context of WorkerScript defined?
    By tube42 in forum [Archived] Qt Quick
    Replies: 4
    Last Post: 2011-08-25, 09:33
  2. Dynamic text on a wallpaper issue (S40)
    By powerpixels in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2010-01-12, 18:46
  3. CEikTimeEditor in dynamic form Issue
    By Shilpa13 in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-12-16, 12:06
  4. dynamic array issue
    By a2sheds in forum Symbian C++
    Replies: 9
    Last Post: 2007-05-08, 09:34
  5. Dynamic Data
    By webassassin in forum Mobile Java General
    Replies: 0
    Last Post: 2004-05-17, 11:34

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •