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

QML CheckBox.checked breaks TableView's styleData.value binding after checked is changed

    XMLWordPrintable

Details

    Description

      import QtQuick 2.0
      import QtQuick.Layouts 1.1
      import QtQuick.Controls 1.2
      
      Rectangle {
          width: 400
          height: 400
      
          ListModel {
              id: testModel
          }
      
          TableView {
              id: table
              model: testModel
              anchors.fill: parent
              focus: true
      
              Component.onCompleted: {
                  for (var i=0; i<=500; i++) {
                      testModel.append({"no":"No " + i, "enabled":false});
                  }
              }
      
              TableViewColumn {
                  role: "no"
                  title: "No."
                  width: 70
              }
              TableViewColumn {
                  role: "enabled"
                  width: 70
              }
              TableViewColumn {
                  role: "enabled"
                  width: 50
                  delegate: CheckBox {
                      anchors.fill: parent
                      checked: styleData.value
                      onClicked: {
                          testModel.setProperty(styleData.row, styleData.role, checked)
                      }
                  }
              }
      
          }
      
      }
      
      1. Run the above code.
      2. The code will create 500 rows with all "enabled" set to false.
      3. Use mouse to tick the CheckBox in first row. Value in "enabled" column changed to "true", as shown in CheckBox1.jpg
      4. Press PageDown a few times slowly, you will see CheckBox in some rows are ticked too, although their styleData.value are actually false, as shown by the "enabled" column which is showing "false". Please see CheckBox2.jpg.
      5. It seems like styleData.value binding is broken after the checked state is changed.

      Attachments

        1. CheckBox2.jpg
          CheckBox2.jpg
          51 kB
        2. CheckBox1.jpg
          CheckBox1.jpg
          46 kB

        Activity

          People

            bachewii Jens
            fxam fxam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: