Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.7, 6.2.2
-
None
-
Ubuntu 20.04 (x86-64)
-
0494b3a98c781abdde321d82b3deb0dc38e985b8 3818ec46b152dce97ebe88c9b1cecde8573e0a13
Description
When a ListView has more items than it can fit in its viewport, it keeps the `currentItem` around even if it is not in the viewport. But if that item is near the end, a new item is added to the end of the model, and that new item is set as the `currentIndex`, the old `currentItem` is erroneously moved to the new `currentItem` location (and becomes hidden underneath it).
I tested 3 versions of Qt. 5.15.7 and 6.2.2 have this issue. 5.15.1 does not have this issue. I've attached a simple test program that can reproduce this error.
To reproduce (generic steps)
- Have a ListView with more items than it can visibly fit.
- Scroll to the end.
- Select the second from the last item.
- Scroll to the beginning.
- Click a button that adds a new item to the end of the ListView's model and set that new index as the current index.
- The previously selected item will appear to be gone (but it is just underneath the last item)
To reproduce (attached example program)
- Scroll to the end.
- Select `Item 18`. (screenshot attached)
- Scroll to the beginning.
- Click `New Item`.
- `Item 18` is now hidden under `Item 20`. (screenshot attached)
Following those steps with the attached program will result in this message in the console (full console is also attached):
>:( Delegate for index 18 is at the wrong location (x = 4000)
(speculation) This seems to be a case that because the ListView is also creating a new item because of the appended item, it calculates a bad `x` value for what was the `currentItem` before setting `currentItem` to the new item.
Attachments
Issue Links
- is duplicated by
-
QTBUG-99264 ListView does not remove all delegates, when its model count is reset to 0
- Closed