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. Is it possible to dynamically remove a particular item in Repeater?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to dynamically remove a particular item in Repeater?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 683 Views 1 Watching
  • 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.
  • H Offline
    H Offline
    Hamzan Martinez
    wrote on last edited by
    #1

    Hello everyone, let's say in this situation:

    Column {
         spacing: 5
    
         Repeater {
              id: repeater
              model: 1
    
         delegate: Rectangle {
                    id: rectangle
                    color: "#000"
              }
         }
    
    Row {
         spacing: 5
         
         Button {
              width: 100
              height: 25
              text: qsTr("Add")
    
              onClicked: {
                   repeater.model+= 1;
              }
         }
         
         Button {
              width: 100
              height: 25
              text: qsTr("Remove")
         
         onClicked: {
              //??
         }
    }
    

    If one would like to use a repeater to dynamically add and remove items, how would one proceed to deleting an item in a particular index? For example, let's say I gave the remove button the index I want to remove in the repeater, when it is clicked it removes it. I have checked the documentation and I could not find any information about this.

    Is this possible? If not, what alternative way can I use that does not involve dynamic object creation?

    Thank you.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Create a ListModel and use that as your model in your Repeater. Delete entries from the ListModel.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1

      • Login

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