Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-87033

CheckBox ButtonGroup The third level is not fully selected, the first level is not half selected

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12
    • Quick: Controls 2
    • None
    • Windows

    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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            tohn tohn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes