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. Drop Area rejects drag sometimes, which results DropArea to break
QtWS25 Last Chance

Drop Area rejects drag sometimes, which results DropArea to break

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 373 Views
  • 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
    Safeer Chonengal
    wrote on last edited by p3c0
    #1

    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
    0

    • Login

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