Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    General and Desktop
    2
    4
    718
    Loading More Posts
    • 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.
    • Diracsbracket
      Diracsbracket last edited by 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-worx 1 Reply Last reply Reply Quote 0
      • Diracsbracket
        Diracsbracket @Diracsbracket last edited by

        @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 Reply Quote 1
        • raven-worx
          raven-worx Moderators @Diracsbracket last edited by

          @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

          Diracsbracket 1 Reply Last reply Reply Quote 0
          • Diracsbracket
            Diracsbracket @raven-worx last edited by 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 }
            }
            
            Diracsbracket 1 Reply Last reply Reply Quote 0
            • Diracsbracket
              Diracsbracket @Diracsbracket last edited by

              @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 Reply Quote 1
              • First post
                Last post