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

CurrentIndex not correct in TableView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.2.0 Alpha
    • 5.1.1
    • Quick: Controls 1
    • None
    • Windows 7, Linux

    Description

      First issue: The currentRow value is set to its previous value if the window lost its focus

      • select e.g. the second entry in table
      • click on "clear selection". CurrentRow is set to -1 and highlight disappears
      • Click on another window and then back to the example application.
      • After the example application has the focus again, the previous selected row is highlighted. I expected that no row is highlighted.

      Second issue: The first row is selected after setting a new model

      • restart the application
      • select the second entry in table
      • click on "set model" (now a new model is set)
      • Now, the first entry is highlighted. I expected that no row is highlighted.

      The issues can be reproduced with following code:

      import QtQuick 2.1
      import QtQuick.Controls 1.0
      import QtQuick.Dialogs 1.0
      import QtQuick.Window 2.0
      
      ApplicationWindow {
        width: 200
        height: 200
      
        ListModel {
          id: firstModel
          ListElement { name: "test 1" }
          ListElement { name: "test 2" }
        }
      
        ListModel {
          id: secondModel
          ListElement { name: "test 3" }
          ListElement { name: "test 4" }
        }
      
        Column {
          Row {
            Button {
              text: "clear selection"
              onClicked: {
                table.currentRow = -1
              }
            }
      
            Button {
              text: "set model"
              onClicked: {
                table.model = secondModel
              }
            }
          }
      
          TableView {
            id: table
            TableViewColumn {
              role: "name"
              title: "Name"
            }
      
            model: firstModel
      
            onCurrentRowChanged: {
              console.log("currentRow: "+ table.currentRow)
              console.trace()
            }
          }
        }
      }
      

      Attachments

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

        Activity

          People

            bachewii Jens
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes