[Qt-qml] DropArea onDropped signal

Gatis Paeglis gatis.paeglis at nokia.com
Thu Dec 15 18:34:57 CET 2011


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"
                     }
                 }
             ]
         }
     }

}







More information about the Qt-qml mailing list