Treeview with delegate in a different file and inline MouseArea
Hi All,
I have a TreeView as shown here
Code:
TreeView {
id:treeView
anchors.fill: parent
model: treemodel
TableViewColumn {
title: "Name"
role: "name"
delegate: EditableDelegate{
MouseArea {
id: columnMouseArea
anchors.fill: parent
acceptedButtons: Qt.RightButton
propagateComposedEvents: true
onClicked: {
console.log("Test")
}
}
}
}
}
The EditableDelegate is defined in a different file
Code:
Item{
Text {
id: label
text: model.name
color: "blue"
font.family: "Open Sans"
verticalAlignment: Text.AlignVCenter
anchors.leftMargin: 5
elide: "ElideRight"
anchors.verticalCenter: parent.verticalCenter
width: parent.width
}
}
However, I get the following error "Cannot assign to non-existent default property" at the treeview where the Mouse area is defined
I need the following design as I want to reuse the delegate with another treeview
Could you suggest a workaround for this approach?
Re: Treeview with delegate in a different file and inline MouseArea
Interesting.
Aside from your item not having any size, it should still have "children" as its default property.
Does this also happen if you are using EditableDelegate as a normal element in a test file? I.e. not as a delegate?
Cheers,
_
Re: Treeview with delegate in a different file and inline MouseArea
It works fine when used as a normal element instead of a delegate.
Found a fix. Thanks for the tip regarding the size. I gave the delegate a fixed width and height and then it started working.