Results 1 to 3 of 3

Thread: Nested Repeaters QML Qt

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Nested Repeaters QML Qt

    Qt Code:
    1. Row {
    2. Rectangle { width: 10; height: 20; color: "red" }
    3. Repeater {
    4. model: 10
    5. Rectangle { width: 20; height: 20; radius: 10; color: "green" }
    6. }
    7. Rectangle { width: 10; height: 20; color: "blue" }
    8. }
    To copy to clipboard, switch view to plain text mode 
    Here I want the color of each middle rectangle to be selected from a list. i.e. Each color has to be different rather than all being green.

    Do I need nested repeaters? How should I go about this?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Nested Repeaters QML Qt

    Each element created by the Repeater has access to the "index" property, which in your case will a value between 0 and 9

    Scroll down a bit further in the Repeater documentation

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    TheIndependentAquarius (1st March 2014)

  4. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: Nested Repeaters QML Qt

    Quote Originally Posted by anda_skoa View Post
    Each element created by the Repeater has access to the "index" property, which in your case will a value between 0 and 9

    Scroll down a bit further in the Repeater documentation

    Cheers,
    _
    I did read that documentation but it didn't strike me that index property can be used to access an array here rather than creating a new repeater.
    Also, I had posted this question in an other fora and other person said the same with a working example.
    Thanks.

Similar Threads

  1. Nested lists in QT QML
    By Raghavendra R M in forum Qt Quick
    Replies: 13
    Last Post: 14th October 2013, 10:27
  2. c++ nested class
    By sonulohani in forum General Programming
    Replies: 1
    Last Post: 25th June 2012, 07:48
  3. Nested Layout
    By starcontrol in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2008, 12:47
  4. nested tables
    By Jeroen van der Waal in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2007, 17:12
  5. Nested Plugins
    By Luis Rodriguez in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2006, 22:00

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.