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. Repeater on SelectionDialog
Qt 6.11 is out! See what's new in the release blog

Repeater on SelectionDialog

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.8k 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.
  • I Offline
    I Offline
    Iktwo
    wrote on last edited by
    #1

    Hi I'm trying to insert ListElements using a repeater but it doesn't work, I have not seen an exmple of something like this being made, the code is:

    @
    SelectionDialog {
    id: singleSelectionDialog
    titleText: "Indice"
    selectedIndex: 1

            model: ListModel {
                Repeater {
                         model: 100
                         ListElement { name: "> " + index }
                     }
            }
        }
    

    @

    The error I get is:

    @
    "ListElement: cannot contain nested elements"
    @

    I think I'm missing something about models, so if there's something I can read that helps me get that working, please tell me, thanks!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blam
      wrote on last edited by
      #2

      A Repeater is a view-type element, like a ListView or a GridView, that is used to create multiple copies of visual items, not non-visual items like the ListElements in a ListModel.

      For your case, you could try populating the model using JavaScript, e.g. when the model is loaded, like this:

      @
      model: ListModel {
      id: model

      Component.onCompleted: {
          for (var i=0; i<100; i++)
              model.append({"name": "> " + i})
      }
      

      }
      @

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Iktwo
        wrote on last edited by
        #3

        Thank you so much, that's exactly what I needed!

        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