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

QItemSelectionModel::currentChanged() wrong on row removal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.14.2, 5.15.2, 6.2.3
    • Core: Item Models
    • None
    • Linux 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
    • Linux/X11

    Description

      QItemSelectionModel::currentChanged() is emitted with the wrong row when a row is removed from the model.

      Starting with a list model with 2 rows (A,B).
      Select the first row (current is index 0,0).
      Remove the first row.
      currentChanged() is emitted.

      Expected:
      The row of current index argument is 0.

      Actual:
      The row of current index argument is 1.

      You can reproduce this with the minimal example attached to this report.

      Context

      I want to create some master / details UI.
      A list of items is presented to the user.
      The list only contains a subset of the attributes of the items.
      When the user chooses an item,
      the details are fetched and presented in the UI.

      I use the currentChanged() signal of the selection model to fetch the details.

      Because I'm not clear about what to do when rows are insert or removed,
      which happens with a filter proxy model, I made a sort of sandbox widget.
      While playing, I have seen this strange behavior when a row is removed.

      I don't know the importance of emitting the currentChanged() signal on rows removal.
      After all, it is not emitted in rows insertion.

      But, I think that the current behavior is wrong.

      Attachments

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

        Activity

          People

            dfaure_kdab David Faure
            scandyna Philippe Steinmann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes