[Qt-qml] DropArea onDropped signal

846 views
Skip to first unread message

Gatis Paeglis

unread,
Dec 15, 2011, 12:34:57 PM12/15/11
to qt-...@qt.nokia.com
Hello,

Today by an accident i discovered DropArea qml element and wanted to try
it out.. i couldn't find any example applications that uses onDropped
signal handler, but i would expect that it logs a message in my test
application ( http://codepaster.europe.nokia.com/?id=48688 ). This is
what i receive in output:

enter
pos
pos
..
..
..
..
pos
exit

Is there anything missing in my code ? Thanks.
------------------------------------
import QtQuick 2.0

Rectangle {
id: win
width: 800
height: 800
color: "lightblue"

MouseArea {
id: requestDrag
drag.target: request
width: 100; height: 100

Rectangle {
id: request
color: "darkred"
width: 100; height: 100
border {color: "black"; width: 3}
anchors {
horizontalCenter: parent.horizontalCenter;
verticalCenter: parent.verticalCenter
}
//z: 3

Drag.keys: "Qt"
Drag.active: requestDrag.drag.active
Drag.hotSpot.x: 5
Drag.hotSpot.y: 5

states: [
State {
when: request.Drag.active
ParentChange {
target: request
parent: win
}
PropertyChanges {
target: request
opacity: 0.5
}
AnchorChanges {
target: request
anchors.horizontalCenter: undefined
anchors.verticalCenter: undefined

}
}
]
}
}

DropArea {
id: dragTargetChunk
keys: "Qt"
width: win.width / 2; height: 102
y: win.height - height; x: 0


onDropped: {
console.log(" Dropped ??? ")
}
onEntered: {
console.log(" enter ")
}
onPositionChanged: {
console.log(" pos ")
}
onExited: {
console.log(" exit ")
}

Rectangle {
id: targetChunk
anchors.fill: parent
color: "green"

states: [
State {
when: dragTargetChunk.containsDrag
PropertyChanges {
target: targetChunk
color: "grey"
}
}
]
}
}

}

_______________________________________________
Qt-qml mailing list
Qt-...@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

andrew.d...@nokia.com

unread,
Dec 15, 2011, 6:35:34 PM12/15/11
to gatis....@nokia.com, qt-...@qt.nokia.com
Hi,

> Today by an accident i discovered DropArea qml element and wanted to try
> it out.. i couldn't find any example applications that uses onDropped signal
> handler, but i would expect that it logs a message in my test application (
> http://codepaster.europe.nokia.com/?id=48688 ). This is what i receive in
> output:
>

> Is there anything missing in my code ? Thanks.

Yes, a drop. Changing the active property from true to false doesn't generate a drop, you'll need to do that yourself by calling the drop function on the Drag object. Try adding the following to your MouseArea.

onReleased: request.Drag.drop()


Andrew

Gatis Paeglis

unread,
Dec 16, 2011, 7:34:02 AM12/16/11
to Den-Exter Andrew (Nokia-MP/Brisbane), qt-...@qt.nokia.com
On 12/16/2011 12:35 AM, Den-Exter Andrew (Nokia-MP/Brisbane) wrote:
> Hi,
>
>> Today by an accident i discovered DropArea qml element and wanted to try
>> it out.. i couldn't find any example applications that uses onDropped signal
>> handler, but i would expect that it logs a message in my test application (
>> http://codepaster.europe.nokia.com/?id=48688 ). This is what i receive in
>> output:
>>
>> Is there anything missing in my code ? Thanks.
> Yes, a drop. Changing the active property from true to false doesn't generate a drop, you'll need to do that yourself by calling the drop function on the Drag object. Try adding the following to your MouseArea.
>
> onReleased: request.Drag.drop()
>
>
> Andrew
Thanks, it works great now.
Reply all
Reply to author
Forward
0 new messages