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

QAbstractItemView in Extended selection mode doesn't handle Shift+click correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.7.0, 5.9.1
    • Widgets: Itemviews
    • None

    Description

      In my application I'm using QTreeView for visualization of objects hierarchy. Selection mode is set to QAbstractItemView::ExtendedSelection. I have a model and selection model attached to it.

      Imagine the following scenario:

      • Click some item in tree view, lets call it 'Object_1'
      • Change current item programmatically using selection model attached to tree view to 'Object_2'
      • Hold down Shift key and click some other item in tree view, let's call it 'Object_3'

      After this I expect that all tree view items between 'Object_2' and 'Object_3' will be selected, but instead I get selected items between 'Object_1' and 'Object_3'.

      Looking in the source code of QAbstractItemView (parent class of QTreeView) I have noticed currentSelectionStartIndex member, that stores the item index from which to start selection when Shift+click action occurs. I didn't find any code that updates currentSelectionStartIndex member in case when the current item is updated through the selection model.

      Also there is another member pressedIndex that is used for selection by mouse dragging. In my opinion it should be also updated, when current index is changed through selection model.

      Attachments

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

        Activity

          People

            richard Richard Moe Gustavsen
            konstp Konstantin Parshutkin
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes