我目前正在尝试更改 QML TreeView 的布局,以使展开图标(您必须单击以显示或隐藏的箭头或三角形)儿童元素)。
我尝试将图标锚定在TreeView的右侧,但是由于某种原因,它无法正常工作,尽管一切正常,它仍保留在左侧。你有什么提示吗?
非常感谢!
TreeView {
id: treeView
anchors.fill: parent
model: treeModResult
style: TreeViewStyle {
branchDelegate: Rectangle {
width: 15; height: 15
color: "#00000000"
anchors.right: treeView.right
Image {
id: expandArrow
source: styleData.isExpanded ? "qrc:/img/icn_arrow_top.svg" : "qrc:/img/icn_arrow_bottom.svg"
sourceSize.width: parent.width
sourceSize.height: parent.height
}
ColorOverlay {
anchors.fill: expandArrow
source: expandArrow
color: "#293147"
}
}
}
}
更新
这是我目前拥有的:
这就是我想要的:
答案 0 :(得分:0)
我遇到了同样的问题,我想出了以下解决方案,因为锚定对我也不起作用..
style: TreeViewStyle {
branchDelegate: Rectangle{
id: expandIcon
x: control.width - width
control.width 表示树状视图的宽度。