TreeView. How to get itemDelegate's property outside itemDelegate?
-
Controls1.TreeView { id: tv1 anchors.fill: parent model: treeModel headerVisible: false itemDelegate: PlanItemDelegate { id: planItemDelegate fullMdl: tv1.model indx: styleData.index closedHeight: mainW.height / 12 open: styleData.selected onButtonMinimizeClicked: { root.changeCurrentIndex(-1) } } rowDelegate: Rectangle { height: ///////// ???? how to make it equal to itemDelegate.height? color: "white" } style: TreeViewStyle { branchDelegate: Rectangle { color: "transparent" height: 80 width: height } } }How to get itemDelegate's height outside itemDelegate?
-
Controls1.TreeView { id: tv1 anchors.fill: parent model: treeModel headerVisible: false itemDelegate: PlanItemDelegate { id: planItemDelegate fullMdl: tv1.model indx: styleData.index closedHeight: mainW.height / 12 open: styleData.selected onButtonMinimizeClicked: { root.changeCurrentIndex(-1) } } rowDelegate: Rectangle { height: ///////// ???? how to make it equal to itemDelegate.height? color: "white" } style: TreeViewStyle { branchDelegate: Rectangle { color: "transparent" height: 80 width: height } } }How to get itemDelegate's height outside itemDelegate?
-
@kshegunov, Yes, it has property
heightrowDelegate: Rectangle { height: planItemDelegate.height ...ReferenceError: planItemDelegate is not defined
And this is real trouble to get this property. I have not found approach to get it. -
@kshegunov, Yes, it has property
heightrowDelegate: Rectangle { height: planItemDelegate.height ...ReferenceError: planItemDelegate is not defined
And this is real trouble to get this property. I have not found approach to get it.@Kofr
Hm, I'm just guessing, but I'd also try reshuffling like this:itemDelegate: planItemDelegate PlanItemDelegate { id: planItemDelegate fullMdl: tv1.model indx: styleData.index closedHeight: mainW.height / 12 open: styleData.selected onButtonMinimizeClicked: { root.changeCurrentIndex(-1) } } rowDelegate: Rectangle { height: planItemDelegate.height color: "white" }This is how I anchor things to one another, at least in a very similar matter.
-
@Kofr
Hm, I'm just guessing, but I'd also try reshuffling like this:itemDelegate: planItemDelegate PlanItemDelegate { id: planItemDelegate fullMdl: tv1.model indx: styleData.index closedHeight: mainW.height / 12 open: styleData.selected onButtonMinimizeClicked: { root.changeCurrentIndex(-1) } } rowDelegate: Rectangle { height: planItemDelegate.height color: "white" }This is how I anchor things to one another, at least in a very similar matter.
@kshegunov it does not work out in this case as this delegate uses
styleData.indexandstyleData.selectedwhich is different for every delegate.
And if I reference this object by id, how do I bind delegate specific properties? -
@kshegunov it does not work out in this case as this delegate uses
styleData.indexandstyleData.selectedwhich is different for every delegate.
And if I reference this object by id, how do I bind delegate specific properties?@Kofr
What isstyleData?And if I reference this object by id, how do I bind delegate specific properties?
I'm not sure I understand the question. What delegate specific properties you want to bind, and to what?
Do you mean something like this:Text { text: planItemDelegate.closedHeight }Do bear in mind, that as I noted my whole experience with QML totals the 2 hours I put in this evening, so I may be completely misleading you ...
-
@Kofr
What isstyleData?And if I reference this object by id, how do I bind delegate specific properties?
I'm not sure I understand the question. What delegate specific properties you want to bind, and to what?
Do you mean something like this:Text { text: planItemDelegate.closedHeight }Do bear in mind, that as I noted my whole experience with QML totals the 2 hours I put in this evening, so I may be completely misleading you ...
@kshegunov said:
indx: styleData.index
closedHeight: mainW.height / 12
open: styleData.selected... indx: styleData.index ... open: styleData.selected ...the internal properties of PlanItemDelegate depends on
styleData.*properties, so if I try to makeitemDelegate: planItemDelegateI can not bind this custom properties. Or Now I think about some js function like
itemDelegate: {var copyObj = planItemDelegate; copyObj.index = Qt.binding(function() {return styleData.index }); copyObj} -
@kshegunov said:
indx: styleData.index
closedHeight: mainW.height / 12
open: styleData.selected... indx: styleData.index ... open: styleData.selected ...the internal properties of PlanItemDelegate depends on
styleData.*properties, so if I try to makeitemDelegate: planItemDelegateI can not bind this custom properties. Or Now I think about some js function like
itemDelegate: {var copyObj = planItemDelegate; copyObj.index = Qt.binding(function() {return styleData.index }); copyObj}@Kofr said:
the internal properties of PlanItemDelegate depends on styleData.* properties, so if I try to make
But they're already bound.
PlanItemDelegate { id: planItemDelegate fullMdl: tv1.model indx: styleData.index //< This is a binding, isn't it? closedHeight: mainW.height / 12 open: styleData.selected onButtonMinimizeClicked: { root.changeCurrentIndex(-1) } }What difference does it make if you create the
PlanItemDelegateand then pass the reference by id, or just pass the reference. I don't see any difference or problem whatsoever. Perhaps I'm wrong, but it really seems the same to me. The only thing I don't know is where thestyleDataobject is defined ...PS.
I have now encounteredstyleData, but am still not sure where it comes from, or rather how it's supposed to be accessed.