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. hwo to change item name in delegate: itemDelegate?
Forum Updated to NodeBB v4.3 + New Features

hwo to change item name in delegate: itemDelegate?

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

    I see this code in sidepanel project example

       model: 10
    
                delegate: ItemDelegate {
                    text: qsTr("Title %1").arg(index + 1)
                    width: parent.width
                }
    
                ScrollIndicator.vertical: ScrollIndicator { }
            }
    

    it create item with name Title 1, Title 2, Title 3, ..., Title 10
    How to change the item name to another different name like Dasboard, Library, Costumer, and so on?
    0_1509930552070_code2.PNG

    1 Reply Last reply
    0
    • 6thC6 Offline
      6thC6 Offline
      6thC
      wrote on last edited by
      #2

      Take a look at:
      https://doc-snapshots.qt.io/qt5-dev/qtquick-modelviewsdata-modelview.html

      1 Reply Last reply
      2
      • ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        Hi,
        you can create a property variant like this : property variant myDifferentNames : ["Dasboard", "Library", "Costumer" ]

        and then

        ...
        delegate: ItemDelegate {
        text: myDifferentNames[index] // qsTr("Title %1").arg(index + 1)
        width: parent.width
        }
        ...

        LA

        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