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

Checkbox checkable state is not working when using ListModel with delegates

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.12.8
    • Quick: Controls 2
    • None
    • Linux/X11

      I have created one ListModel containing name, checkableData and checkedData as roles. When setting the model to the ListView containing CheckBox as delegate with checkable as false, the checkable property doesn't work and allow me to check/uncheck the CheckBox. This happens only when using the model and when the checked state is set to true. Here is the example code for reference:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          ListModel {
              id: fruitModel
      
              ListElement {
                  name: "Apple"
                  checkedData: true
                  checkableData: false
              }
              ListElement {
                  name: "Orange"
                  checkedData: false
                  checkableData: false
              }
              ListElement {
                  name: "Banana"
                  checkedData: true
                  checkableData: false
              }
          }
      
      
          ListView {
              anchors.fill: parent
              model: fruitModel
              snapMode: ListView.NoSnap
              boundsBehavior: ListView.StopAtBounds
              headerPositioning: ListView.OverlayHeader
              ScrollBar.vertical: ScrollBar {
                  id: scrollBar
                  policy: ScrollBar.AsNeeded
              }
              delegate: CheckBox {
                  checkable: checkableData
                  text: name
                  checked: checkedData
              }
              spacing: 5
              orientation: ListView.Vertical
              interactive: false
          }
      }
      

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            sonulohani Sonu Lohani
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes