PDA

View Full Version : Treeview with delegate in a different file and inline MouseArea



volcano
16th June 2016, 04:25
Hi All,

I have a TreeView as shown here



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



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?

anda_skoa
16th June 2016, 10:47
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,
_

volcano
16th June 2016, 11:19
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.