Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12
-
None
Description
The third level is not fully selected, the first level is not half selected
BambooTreeListView.qml
import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 ListView{ id: listView clip: true property var childGroup Layout.fillHeight: true ScrollBar.vertical: ScrollBar { } }
import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 Rectangle { id: itemTree width: 1920 height: 1440 property var checkedArray: [] //当前已勾选的items property int spacing: 10 //项之间距离 property int indent: 5 //子项缩进距离,注意实际还有icon的距离 property int itemHeight: 50 Component{ id: delegateComponent ItemDelegate{ id: delegate width: listView.width checkable: true contentItem: ColumnLayout { spacing: 10 ButtonGroup { id: parentChildGroup exclusive: false checkState: parentBox.checkState } CheckBox { id: parentBox text: modelData.className font.bold: true //elide: Text.ElideRight //Layout.fillWidth: true Layout.preferredWidth: 200 checkState: parentChildGroup.checkState ButtonGroup.group: delegate.parent.parent.childGroup ? delegate.parent.parent.childGroup : null } ColumnLayout { id: grid visible: false Layout.fillHeight: true Layout.preferredHeight: childTree.contentHeight// (itemHeight + 10) * modelData.subnodes.length BambooTreeListView { id: childTree height: itemHeight model: modelData.subnodes delegate: delegateComponent Layout.fillWidth: true Layout.fillHeight: true childGroup: parentChildGroup } } } states: [ State { name: "expanded" when: delegate.checked PropertyChanges { target: grid visible: true } } ] } } BambooTreeListView{ id: listView anchors.fill: parent delegate: delegateComponent ScrollBar.vertical: ScrollBar { } } Component.onCompleted: { setTestDataB(); } function setTestDataB(){ listView.model=JSON.parse('[ { "className":"1 one", "istitle":true, "subnodes":[ { "className":"1-1", "istitle":true, "subnodes":[ {"className":"1-1-1","isoption":true, "subnodes":[]}, {"className":"1-1-2","isoption":true, "subnodes":[]} ] }, { "className":"1-2", "istitle":true, "subnodes":[ {"className":"1-2-1","isoption":true, "subnodes":[]}, {"className":"1-2-2","isoption":true, "subnodes":[]} ] } ] }, { "className":"2 one", "istitle":true, "subnodes":[ {"className":"2-1","istitle":true, "subnodes":[]}, { "className":"2-2", "istitle":true, "subnodes":[ {"className":"2-2-1","isoption":true, "subnodes":[]}, {"className":"2-2-2","isoption":true, "subnodes":[]} ] } ] }, {"className":"3 one","istitle":true, "subnodes":[]}, { "className":"4 one", "istitle":true, "subnodes":[ {"className":"4-1","istitle":true, "subnodes":[]}, {"className":"4-2","istitle":true, "subnodes":[]} ] } ]') } }
BambooTreeView.qml