Results 1 to 5 of 5

Thread: Iterating through Items put within a QML Column element

  1. #1
    Join Date
    Dec 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Iterating through Items put within a QML Column element

    I have a QML application with several Rectangle Elements put within a Column Element.
    Is there any way i can Iterate through these Column using some index .. so that i can change property of a particular rectangle within the the Column .

  2. #2
    Join Date
    Oct 2009
    Location
    Mantova, Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Iterating through Items put within a QML Column element

    up on this post because i'm interested.
    Iterating over (and if is possible, delete) dynamically created elements (with createObject) in QML column.

  3. #3
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Iterating through Items put within a QML Column element

    Would not be sufficient just to create objects inside JavaScript, like mentioned in Qt docs, store them, for example in an array, and than call destroy() method on the objects, that are no longer needed ? To be precise objects' parent should be the column element, which would placed them inside of it...
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  4. #4
    Join Date
    Oct 2009
    Location
    Mantova, Italy
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Iterating through Items put within a QML Column element

    I've tried with an array but for some reason is not useful for my purpose. But i've found a solution that works fine form me.
    Every time that a new object is created with createObject i do this:

    var obj = [].createobject();
    obj.variousData=someVariusDataPassed;
    obj.objectName: "dynObject_"+identificator

    and from c++ now is simple find and use the created object via his objectName.
    The identificator is a number passed from c++ when it call the function containing the previous code.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Iterating through Items put within a QML Column element

    Quote Originally Posted by chinmay_s View Post
    I have a QML application with several Rectangle Elements put within a Column Element.
    Is there any way i can Iterate through these Column using some index .. so that i can change property of a particular rectangle within the the Column .
    Yes, you can iterate children, for example:
    Qt Code:
    1. for (var i = 0; i < column.children.length; ++i)
    2. column.children[i].width = column.width;
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. How to get count of items in QListView column?
    By qt-closer in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2010, 15:40
  2. Iterating with QDirIterator seems slow
    By TheShow in forum Qt Programming
    Replies: 1
    Last Post: 6th January 2010, 17:55
  3. Iterating over QGroupBox
    By Doug Broadwell in forum Newbie
    Replies: 3
    Last Post: 26th February 2007, 23:13
  4. qt4 - iterating thru QListView
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 27th November 2006, 00:38
  5. Replies: 1
    Last Post: 24th August 2006, 12:44

Tags for this Thread

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.