Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QML: Avoid empty space when drag/drop between two views
Qt 6.11 is out! See what's new in the release blog

QML: Avoid empty space when drag/drop between two views

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.8k 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi
    I am using the QtQuick's Drag and Drop example (the Tiles part) to drag and drop tiles (representing buttons) from the list onto the grid as a way to dynamically lay out these buttons.

    When "removing" (i.e. reparenting) the tile from the list, an empty space is left. I would like the list to automatically reorganize to close this gap. Is that possible using the approach in the example where the drag/drop is simply done by reparenting the tile?

    0_1521646125793_1cbfdb62-3c73-4601-8315-e33f70349917-image.png

    Thanks for your help!

    raven-worxR 1 Reply Last reply
    0
    • DiracsbracketD Diracsbracket

      @raven-worx
      Yes, I mean those red tiles. I tried using your suggestion (the Column item's id is redSource) as in the snippet below, but this does not do anything? I put the call to forceLayout() in a StateChangeScript inside the drag.active state, but to no effect.

      State {
          when: mouseArea.drag.active
          ParentChange { target: tile; parent: window.contentItem}
      
          StateChangeScript {
               name: "testScript"
                script: {console.debug("test"); redSource.forceLayout()}
         }
      
         AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
      }
      
      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #4

      @Diracsbracket
      This question was answered on the StackOverflow forum.

      https://stackoverflow.com/questions/49410096/qml-avoid-empty-spaces-when-drag-and-drop-between-views/49413096#49413096

      1 Reply Last reply
      1
      • DiracsbracketD Diracsbracket

        Hi
        I am using the QtQuick's Drag and Drop example (the Tiles part) to drag and drop tiles (representing buttons) from the list onto the grid as a way to dynamically lay out these buttons.

        When "removing" (i.e. reparenting) the tile from the list, an empty space is left. I would like the list to automatically reorganize to close this gap. Is that possible using the approach in the example where the drag/drop is simply done by reparenting the tile?

        0_1521646125793_1cbfdb62-3c73-4601-8315-e33f70349917-image.png

        Thanks for your help!

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @Diracsbracket
        do you mean the red/blue source lists (on the left and right side)? If so these are Column types and you can call forceLayout() on them.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        DiracsbracketD 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @Diracsbracket
          do you mean the red/blue source lists (on the left and right side)? If so these are Column types and you can call forceLayout() on them.

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by Diracsbracket
          #3

          @raven-worx
          Yes, I mean those red tiles. I tried using your suggestion (the Column item's id is redSource) as in the snippet below, but this does not do anything? I put the call to forceLayout() in a StateChangeScript inside the drag.active state, but to no effect.

          State {
              when: mouseArea.drag.active
              ParentChange { target: tile; parent: window.contentItem}
          
              StateChangeScript {
                   name: "testScript"
                    script: {console.debug("test"); redSource.forceLayout()}
             }
          
             AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
          }
          
          DiracsbracketD 1 Reply Last reply
          0
          • DiracsbracketD Diracsbracket

            @raven-worx
            Yes, I mean those red tiles. I tried using your suggestion (the Column item's id is redSource) as in the snippet below, but this does not do anything? I put the call to forceLayout() in a StateChangeScript inside the drag.active state, but to no effect.

            State {
                when: mouseArea.drag.active
                ParentChange { target: tile; parent: window.contentItem}
            
                StateChangeScript {
                     name: "testScript"
                      script: {console.debug("test"); redSource.forceLayout()}
               }
            
               AnchorChanges { target: tile; anchors.verticalCenter: undefined; anchors.horizontalCenter: undefined }
            }
            
            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by
            #4

            @Diracsbracket
            This question was answered on the StackOverflow forum.

            https://stackoverflow.com/questions/49410096/qml-avoid-empty-spaces-when-drag-and-drop-between-views/49413096#49413096

            1 Reply Last reply
            1

            • Login

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