Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can i apply delegate of repeater for ObjectModel in QML?

How can i apply delegate of repeater for ObjectModel in QML?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 452 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dan Nguyen
    wrote on last edited by Dan Nguyen
    #1
    ApplicationWindow {
        // @disable-check M16
        visible: true
        // @disable-check M16
        width: 640
        // @disable-check M16
        height: 480
        Grid {
            id:grid
            width: 200; height: 100
            columns: 3
            rows: 3
            columnSpacing: 2
            rowSpacing: 2
    
            Repeater{
                id:repeater
                model:objModel
                delegate: Component{
                    Rectangle{
                        width: 150
                        height: 150
                        border.color: "black"
                        border.width: 5
                    }
                }
            }
    
            ObjectModel{
                id:objModel
                Rectangle{
                    width: 100
                    height: 100
                    color: "red"
                }
                Rectangle{
                    width: 100
                    height: 100
                    color: "blue"
                }
            }
        }
    

    }

    I build TableLayoutPanel control custom use Grid with Repeater to generate item.I definition delegate for repeater.But when i pass model I use ObjectModel.It dont use delegate(follow QT DOCUMENTATION).So How can i apply delegate of repeater for ObjectModel?
    I want when pass ObjectModel each item has a Rectangle with property like I definition in delegate.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved