Results 1 to 3 of 3

Thread: Binding properties of dynamically created QML objects

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Binding properties of dynamically created QML objects

    Hi all!

    I have some objects that I create dynamically in QML, and I would like to bind some of these objects' properties to properties of static objects.

    I have used a ListModel to manage the dynamically created objects as suggested here.

    Using this ListModel I have no problem looping through all the objects and accessing them, but I can't figure out how to bind their properties to other objects.

    The same site suggests using the Binding component, but I do not understand how to use it.

    Without the Binding component, I have tried this:

    Qt Code:
    1. for (var i = 0; i < listModel.count; ++i)
    2. {
    3. var dynObj = listModel.get(i).obj // Gives me access to the object
    4. dynObj.someProperty = Qt.binding(function() {return staticObject.otherProperty}) // I want this to work
    5. }
    To copy to clipboard, switch view to plain text mode 

    This sets the value of dynObj.someProperty to staticObject.otherProperty at the time this call is made, but when otherProperty changes later on QML complains about "Something related to the property not being available, I dont' remember of the top of my head, beacuse I'm writing this at home and I do not have access to the code at this moment."


    Any ideas?
    Last edited by Obi-Wan; 5th August 2017 at 11:44.

Similar Threads

  1. QObject dynamic properties and QML binding
    By ugluk in forum Qt Quick
    Replies: 5
    Last Post: 21st December 2012, 23:43
  2. Replies: 3
    Last Post: 9th February 2011, 11:07
  3. Dynamically created buttons.
    By Tomasz in forum Newbie
    Replies: 26
    Last Post: 2nd December 2010, 09:40
  4. Connecting dynamically added properties
    By stefkeB in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2008, 15:19
  5. Replies: 7
    Last Post: 18th July 2006, 21:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.