How can i get the TableView column header click. ? (QML).

  • Code block:

            // Customizing column header
            headerDelegate:Rectangle {
                height: 30
                anchors.topMargin: -20
                anchors.rightMargin: -5
                color: control.colHeaderColor
                implicitWidth: 40
                BorderImage {
                    source: control.tabTitleImage
                    verticalTileMode: BorderImage.Stretch
                    anchors { top:; right: parent.right; bottom: parent.bottom;  }
                Text {
                    id: textItem
                    text: styleData.value
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: styleData.textAlignment
                    elide: Text.ElideRight
                    color: control.enableStatus ? control.itemTextColor : control.disableTextColor
                    renderType: Text.NativeRendering
                    anchors { fill: parent; leftMargin: 7; }
                    font { bold: true; pointSize: 12; }
               anchors.fill: parent
                // this click is not called. 
                console.log("Header Clicked..")

    The mouse area click in the Headerdelegate Rectangle is not called. Can anyone tell me the solution. i am blocked actually.

  • Hello!

    In the docs it says
    styleData.pressed - true when the column is being pressed

    Therefore try...

                        Connections {
                            target: styleData
                            onPressedChanged: console.debug("Header Clicked..")


  • That's cool ..!
    Many thanks Pilk ..!
    Meanwhile i observed one thing, its been called multiple time for single click (pressed and clicked are different things rite ? ). Any way i think i can go ahead with this..!! thanks again..!

  • Maybe an if statement or something..
    Look at the docs (press F1)!
    Im guessing the multiple events are corresponding to each column header... so I guess you also have styleData.column to play with :)

    onPressedChanged:  {
     if (syleData.Pressed === true) {
     else {

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.