How do I emit signal while clicking TableViewColumn?



  • I would like to add a MouseArea or Button to a TableViewColumn to perform specific tasks. However, if I add one of the above type, it overrides the "click" event of TableViewColumn so that I lose row selection by click.

    Here is an example code. The row is not switching when I click it in the area of the last column:

    TreeView {
    clip: true id: mapsTreeView
    objectName: "mapsTreeView"
    model: theModel

    TableViewColumn {
        width: 100
        role: "name_role"
        title: "Map"
    }
    TableViewColumn {
        width: 50
        role: "description_role"
    }
    TableViewColumn {
        id: imageColumn
        width: 20
        role: "image_role"
        delegate: Item {
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    mapsTreeView.sigChangeState()
                }
            }
            Image {
                anchors.fill: parent
                width: 5
                source: "icon" + styleData.value + ".png"
            }
        }
    
    }
    signal sigChangeState()
    

    }


Log in to reply
 

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