PDA

View Full Version : QML DropArea: drop an external file does not work



ddonate
17th October 2016, 12:44
Hi,

I have a QML application and I would like to enable an area to drop there an external file (dragged from Windows explorer, for instance) and show the file path in my application.

I have a really simple test qml to try, but I can not drop anything ("not accepted" cursor is displayed when I enter my DropArea dragging the file).

My code:



import QtQuick 2.1
import QtQuick.Controls 1.0

ApplicationWindow {
title: qsTr("Drop Area test")

width: 800
height: 600

visible: true

DropArea {
id: drop
anchors.fill: parent

enabled: true

onEntered:
console.log("entered");

onExited:
console.log("exited")

onDropped:
console.log("dropped")
}

Text {
id: textDrop
anchors.centerIn: parent
text: "Drop an element"
}
}

I supponse I am doing anything wrong, but I can not fix it...

Thanks in advance,
Diego

anda_skoa
17th October 2016, 20:02
You might have to accept the event in your signal handlers.

Cheers,
_

ddonate
18th October 2016, 09:57
Thanks for your time. It seemed to be something related to my QT installation, I reinstalled QT package and now it works... I don't know why!!!