QtQuick:更改树视图中的展开图标

QtQuick: Change expand icon in TreeView

本文关键字:图标 视图 QtQuick      更新时间:2023-10-16

我想在树视图中交换标准展开图标,可以吗?我想我需要为图像定义状态。

您可以在TreeViewStyle中提供branchDelegate,并使用styleData.isExpanded来确定其状态。例如

TreeView {
    style: TreeViewStyle {
        branchDelegate: Rectangle {
            width: 15; height: 15
            color: styleData.isExpanded ? "red" : "green"
        }
    }
    //...
}