PDA

View Full Version : Get value from single columned table when clicked on



kristian1112
21st November 2015, 20:57
After some research I get this far but now I don't know why the value doesn't show up. Any help? :confused:



TableView {
id: view

anchors.margins: 10
anchors.fill: parent
model: dataModel
clip: true

TableViewColumn {
width: 100
title: "Name"
role: "fileName"
}

itemDelegate: Item {
Text {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
renderType: Text.NativeRendering
text: styleData.value
}
}

MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.LeftButton
propagateComposedEvents: true

onPressed:
{

if(mouse.button == Qt.LeftButton){
console.log(view.value) // ??? styleData.value doen't work neihter
}
mouse.accepted = false
}
onReleased: mouse.accepted = false
onPressAndHold: mouse.accepted = false
}
}

anda_skoa
22nd November 2015, 07:47
You want to have the mouse area inside the delegate.

Cheers,
_