Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Drag and drop broken when scrolling
QtWS25 Last Chance

Drag and drop broken when scrolling

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AndersDK
    wrote on last edited by
    #1

    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?

    Gojir4G 1 Reply Last reply
    0
    • A AndersDK

      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?

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      @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.

      GrecKoG 1 Reply Last reply
      0
      • A Offline
        A Offline
        AndersDK
        wrote on last edited by
        #3

        Thanks for the suggestion. The error persist even if I remove the ScrollView

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AndersDK
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • Gojir4G Gojir4

            @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.

            GrecKoG Offline
            GrecKoG Offline
            GrecKo
            Qt Champions 2018
            wrote on last edited by
            #5

            @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) ?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AndersDK
              wrote on last edited by
              #6

              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
              displayMarginEnd

              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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved