Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How do I perform simple drag and drop?

    QML and Qt Quick
    2
    2
    541
    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.
    • B
      bobbaluba last edited by

      I'm trying to drag and drop one square to another, using this code:

      @//where I want to drag from
      Connector {
      id: connector
      anchors.right: parent.right
      MouseArea {
      id:dragArea
      anchors.fill: parent
      drag.target: dragDummy
      onReleased: {
      console.log("Released");
      }
      Rectangle{
      id:dragDummy
      color:'pink'
      width:radius2
      height:radius
      2
      radius: 4
      }
      }
      }@

      @//where i want to drop something
      Connector {
      id: connector
      anchors.left: parent.left
      DropArea{
      anchors.fill: parent
      Rectangle{
      anchors.fill: parent
      color: "blue"
      }
      onDropped: {
      console.log("Dropped");
      }
      }
      }@

      I can see the pink circle moving when i drag it, but "Dropped" is never printed when I release it in the blue area.

      What am I missing?

      1 Reply Last reply Reply Quote 0
      • V
        Vincent007 last edited by

        compare your code with Qt example.

        QTPATH\examples\quick\draganddrop

        1 Reply Last reply Reply Quote 0
        • First post
          Last post