Drag and drop broken when scrolling
-
wrote on 12 Jul 2019, 05:56 last edited by
Hello
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?
-
Hello
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?
wrote on 12 Jul 2019, 06:55 last edited by@AndersDK Hi,
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.
-
wrote on 12 Jul 2019, 09:58 last edited by
Thanks for the suggestion. The error persist even if I remove the ScrollView
-
wrote on 12 Jul 2019, 10:17 last edited by
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?
-
@AndersDK Hi,
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.
@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
cacheBuffer
) ? -
wrote on 12 Jul 2019, 10:47 last edited by
hey
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
displayMarginBeginning
displayMarginEndto 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
1/6