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. Custom component with delegate and index.

Custom component with delegate and index.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qtquickqml
4 Posts 3 Posters 1.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.
  • shavS Offline
    shavS Offline
    shav
    wrote on last edited by
    #1

    Hi everyone!

    Maybe some of you know how to create custom component with delegate where I can use ‘index’ value as in ListView Delegate? I need to create a special component where user must set some QML view item as a delegate and if user set model as a int value I want to use index in delegate component for indicate which is element was created.

    Mac OS and iOS Developer

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Not completely understood the qn. What I understood is that you would like to use the model index as the value in delegate component. If this is the question, you can define the component like this.

      Component {
      id : comp
      Text {text : index}
      }

      U can use this for delegate property in listView. Hope this is what u r asking for. If not help me to understand more.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        What about using an embedded ListView, Repeater or Instantiator?

        1 Reply Last reply
        0
        • shavS Offline
          shavS Offline
          shav
          wrote on last edited by
          #4

          Thanks for the reply!

          I'll try to explain more detail my problem: I have a UI component with list view as a content. My component was created by C++ with loading a QML file as a content which user see when using my component. In C++ class I have a property 'delegate' which I using in QML content file for set a ListView delegate. All works fine but when I try to set delegate component and use inside index I receive error 'index is not a function of property'. My question is how I need to set delegate in C++ class which give me to use model index in a delegate element.

          I think will be more detail if I share my component. Please check this link.

          Mac OS and iOS Developer

          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