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 Item from list clipping problem and drag and drop inside ScrollView
Forum Updated to NodeBB v4.3 + New Features

Drag Item from list clipping problem and drag and drop inside ScrollView

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 2.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Schneidi
    wrote on 22 Apr 2014, 11:27 last edited by
    #1

    Hello guys I need some help with Drag 'n' Drop in qml.
    I have a ScrollView which hold a grid of users an assigned packages.
    I have to implement drag and drop functionality so that packages can be drag from one user to another.
    This is basically not the problem but I'm struggeling with the request Rectangle in the example below and
    the behavior the the ScrollView in combination with the MouseAreas.

    At first the request object. If I drag an packageItem the request Rectangle is used to visualize the drag.
    But the request Rectangle is always rendered behind every packageItem which was build after the currently draged packageItem. I experienced this in several examples. Even in the Qt Quick draganddrop example.

    Imagine a List of three Items. I drag the first Item and it will be displayed behind the second and the third Item.
    If I drag the second Item it will be displayed in front of the first Item but behind the third item and if I drag the third Item it will be displayed in front of the first and the second Item. I hope you understand what I'm trying to explain.

    What can I do to render the request Rectangles infront of every packageItem ?
    I tried to set the z property but this has absolutely no effect.

    The second problem is that I use a ScrollView a container for the package lists so i can scroll through the lists.
    But if i have the mouseAreas for the drag and drop handling in the lists i can't flick the scrollView anymore.

    What can I do to implement the drag and drop inside the ScrollView without interfering with the scrolling of the view ?

    I Hope you guys can help me with this problems.
    Thanks you

    Here is the code:
    https://gist.github.com/anonymous/11174995

    1 Reply Last reply
    0
    • T Offline
      T Offline
      th.thielemann
      wrote on 4 Aug 2015, 06:04 last edited by th.thielemann 8 Apr 2015, 08:12
      #2

      My solution for two scrollview items and drag and drop:

      1. Start with a simple list and implement the drag and drop
      2. Duplicate the lists: Drag and drop between the lists should be possible. My list views are called listViewSource and listViewTarget
      3. Within both lists add to your mouse area and handling for the z property. The source item shall have a higher z than the target item

      <code>
      ListView {
      id: listViewSource
      ...
      delegate: Rectangle {
      id: dragRectSource
      ...
      MouseArea {
      id: mouseAreaSource
      anchors.fill: parent
      drag.target: dragRectSource

                          drag.onActiveChanged: {
                              if (mouseAreaSource.drag.active) {
                                  listViewSource.dragItemIndex = index;  // dragItemIndex is a custom property of ListView to store the current index
                                  scrollViewSource.z = scrollViewTarget.z + 1
                              }
                              else {
                                  scrollViewSource.z = 0
                              }
      
                              dragRectSource.Drag.drop();
                              scrollViewSource.viewport.clip = ! mouseAreaSource.drag.active
                              scrollViewTarget.viewport.clip = ! mouseAreaSource.drag.active
                          }
                      }
      

      <code>

      1. Surround both ListView items with ScrollView items (scrollViewSource, scrollViewTarget). Drag and drop should be possible, but the drag item is clipped.
      2. Add the following to drag.onActiveChanged
        scrollViewSource.viewport.clip = ! mouseAreaSource.drag.active
      3. While clipping is disabled add some overlays on top of ScrollView
      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