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. HorizontalHeaderView - textRole & custom delegate
Forum Updated to NodeBB v4.3 + New Features

HorizontalHeaderView - textRole & custom delegate

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 277 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by dheerendra
    #1

    HorizontalHeaderView has property called textRole. & value for this property is role defined in model. However If I define the custom delegate, textRole is not applicable. Delegate takes precedence over the textRole.

    Documentation is not very clear about this.

    HorizontalHeaderView {
            id: horizontalHeader
            width: parent.width
            height: 100
            delegate:del2
            textRole: "fone_1"
            model : myModel
            columnSpacing: 2
            rowSpacing: 2
        }
        Component{
            id : del2
            Rectangle{
                implicitWidth: horizontalHeader.width/4;
                implicitHeight: 50
                width: 200;height: 50;color: "blue";
                Text {
                    text : fone_1
                }
            }
        }
    

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

    1 Reply Last reply
    1
    • A Offline
      A Offline
      afalsa
      wrote on last edited by afalsa
      #2

      Hello!

      I'm not quite sure I'm understanding your problem...

      If you add this as it is:

       Rectangle{
      
                  required property string fone_1
                  implicitWidth: horizontalHeader.width/4;
                  implicitHeight: 50
                  width: 200;height: 50;color: "blue";
                  Text {
                      text : fone_1
                  }
      

      You should change "fone_1" for whatever you have written in your model.

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

        Thanks @afalsa. Yes. Output is not an issue. If you specify both delegate & textRole, textRole has no impact. Delegate takes priority. If you remove the delegate, then textRole kicks in. There is no bug also. Need to docs clear about this.

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

        1 Reply Last reply
        2

        • Login

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