volcano
31st March 2016, 11:03
Hi all,
I'm using QML treeview 5.6, I have a QAbstractItemModel subclass model which is set to the model of the treeview.
The model has roles such as visible and name.
The tree view has a tableview column
TableViewColumn {
title: "Name"
role: "name"
resizable: true
}
And in the item delegate, I'm accessing the name as "model.name" and visible as "visible"
Delegate has a name and an icon field.
Text {
id: label
text: model.name
font.family: "Open Sans"
font.pixelSize: 13
font.weight: Font.DemiBold
elide: "ElideRight"
anchors.verticalCenter: parent.verticalCenter
width: parent.width - iconImage.width - 25
}
Image {
id: iconImage
height: 24
anchors.right: parent.right
anchors.rightMargin: 25
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
source: model.visible?"qrc:/icons/Visible.png": "qrc:/icons/Invisible.png"
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
qmlApp.onTreeItemVisibleChanged(treeView.model.mod elIndex(model.index), !model.visible)
}
}
}
The reset of the property is happening in the C++ model, however it's not reflected in the QML file.
Kindly advice what i'm missing
I'm using QML treeview 5.6, I have a QAbstractItemModel subclass model which is set to the model of the treeview.
The model has roles such as visible and name.
The tree view has a tableview column
TableViewColumn {
title: "Name"
role: "name"
resizable: true
}
And in the item delegate, I'm accessing the name as "model.name" and visible as "visible"
Delegate has a name and an icon field.
Text {
id: label
text: model.name
font.family: "Open Sans"
font.pixelSize: 13
font.weight: Font.DemiBold
elide: "ElideRight"
anchors.verticalCenter: parent.verticalCenter
width: parent.width - iconImage.width - 25
}
Image {
id: iconImage
height: 24
anchors.right: parent.right
anchors.rightMargin: 25
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
source: model.visible?"qrc:/icons/Visible.png": "qrc:/icons/Invisible.png"
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
qmlApp.onTreeItemVisibleChanged(treeView.model.mod elIndex(model.index), !model.visible)
}
}
}
The reset of the property is happening in the C++ model, however it's not reflected in the QML file.
Kindly advice what i'm missing