Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Drag and Drop to desktop or file manager



  • This one is kinda fun. I currently have drag from the desktop/file manager working as my DropArea gets a url for me to use. Now I am trying to detect the drop area outside of the application.

                                            Drag.active: mouseArea.drag.active
                                            Drag.hotSpot.x: 0
                                            Drag.hotSpot.y: 0
                                            Drag.mimeData: { "text/uri-list": fileUrl }
                                            Drag.supportedActions: Qt.CopyAction
                                            Drag.dragType: Drag.Automatic
                                            Drag.onDragStarted: {
                                            }
                                            Drag.onDragFinished: {
                                                
                                                if(dropAction === Qt.CopyAction){
                                                    console.log("drag copy")
                                                }
                                            }
    

    I have 2 problems.

    • How do I detect if this landed in a DropArea or outside the app?
    • How do I detect where it dropped outside the app? (there is no DropArea for this)

    In the above code I see the "drag copy" message get printed as expected when dropping outside the app. I cannot see anything in the docs to indicate how to get the drop area/url that I dropped to outside the app. Is there a global drop area or something?


Log in to reply