Qt Forum

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

    Drop Area rejects drag sometimes, which results DropArea to break

    QML and Qt Quick
    1
    1
    266
    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.
    • S
      Safeer Chonengal last edited by p3c0

      I have observed an issue with DropArea. Here what I am doing is to drag and drop small rectangles onto a DropArea. After consecutive drag drop operations, DropArea rejects the drag. Then after that DropArea doesnt accept any drag, and it remains inactive. I have to close my application to make it work again.
      I have found a related bug: https://bugreports.qt.io/browse/QTBUG-39453
      Is there any workaround to fix it?
      I dont know why the DropArea is rejecting the drag for the first time which results the failure.
      Following is the code

      Rectangle {
                  id: dragRect
                  width: 500
                  height: 200
      
                  MouseArea {
                      id: mouseArea
                      anchors.fill: parent
                      drag.target: dragRect
      
                      drag.onActiveChanged: {
                          if (mouseArea.drag.active) {
                                // do something at drag start
                          }
      
                          var dragResult = dragRect.Drag.drop();
      
                          if(dragResult === Qt.IgnoreAction)
                          {
                              if(!mouseArea.drag.active)
                              {
                                  console.log("Drop ignored. Item must be restored.");
                              }
                          }
                      }
                  }
      
                  Drag.active: mouseArea.drag.active
                  Drag.hotSpot.x: dragRect.width / 2
                  Drag.hotSpot.y: dragRect.height / 2
              }
      
      
      Rectangle{
              id: mainViewArea
              objectName: "mainViewArea"
              width: parent.width
              height: parent.height
             
              color: Qt.lighter(outerViewArea.color, 1.25)
      
              // The entire view are must be a target for drag and drop operations
              DropArea {
                  id: dragTarget
      
                  property string colorKey
                  property alias dropProxy: dragTarget
      
                  width: parent.width
                  height: parent.height
      
                  onDropped: {
                      drop.visible = false
                      drop.acceptProposedAction()
      
                      console.log("dropped")
                  }
      
                  Rectangle {
                      id: dropRectangle
      
                      anchors.fill: parent
      
                      states: [
                          State {
                              when: dragTarget.containsDrag
                              PropertyChanges {
                                  target: dropRectangle
                                  color: Qt.darker(mainViewArea.color, 1.25)
                              }
                          }
                      ]
                  }
              }
      

      Ignore any bracket closing issue found

      Edit - Please follow Markdown syntax rules - p3c0

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