Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Drag and drop broken when scrolling
I have a ListView which gets its elements from c++ through a model. This ListView is placed inside a ScrollView. It seems to work fine. To make it possible to switch the order of the elements in the ListView I've implemented a drag and drop function on the Elements. This also works fine. The problem is that the list is longer than the user UI (hence the use of the ScrollView), so when I start dragging an element, and need to scroll the ScrollView while dragging it, to get from for example the top to the bottom, the element disapears and sometimes if the scroll is very long the dragging just stops.
Anybody have an idea why this is happening, and maybe how to fix it?
Gojir4 last edited by
ListView are already scrolling when content is bigger than height. It inherits from Flickable so ScrollView is not necessary. I don't know if this is what causing the issue, but you may try without the ScrollView.
Thanks for the suggestion. The error persist even if I remove the ScrollView
After some debugging i might have found the problem, but not the solution.
I think when the original placement of my element gets out of the window, then the ListView tells not to generate the element/or hide it to save memory. However, this causes it not to show anymore.
Any ideas how to fix this?
@Gojir4 ScrollView is meant to wrap content in a Flickable OR decorate an existing Flickable with scroll bars. So it's a valid usecase.
@AndersDK Did you figure out how to scroll the ListView when dragging? Does your drag and drop works correctly when scrolling? Does it stop working only when you scroll a lot and it triggers the destruction of the delegate (see ListView's
It disapears exactly when the original placement gets out of the view, so I'm pretty sure it is the cause. I fixed it by setting the
to large numbers. Don't know if that is a good fix, but I guess it is OK as long as I know that the list will never contain a lot of elements.
But if there is a more elegant solution I would like to know