PDA

View Full Version : Dragging an Image in QLabel using mouse



A9am
24th October 2011, 08:55
Hi All,


I have an image in QLabel.I want to drag the image using mouse.Which class should I use for that?Can anyone please help me? Should I use QDrag ??

m.azeemanwar
24th October 2011, 09:11
Hi A9am,
if you are asking how to drag image in qml it will be as..may this example could help you

Rectangle { id: mainRect; width: 600; height: 200; color: "white" Image { id: pic; source: "face-smile.png" anchors.verticalCenter: parent.verticalCenter opacity: (600.0-pic.x) / 600; MouseArea { anchors.fill: parent drag.target: pic drag.axis: "XAxis" drag.minimumX: 0 drag.maximumX: mainRect.width-pic.width } } }

A9am
24th October 2011, 09:22
Thanks m.azeemanwar for your reply. But I am not using qml. I have one QLabel and I have set the pixmap.Can I drag that Image using mouse?

wladek
24th October 2011, 11:32
Hi,

Have a look at the Drag and Drop examples (http://doc.qt.nokia.com/latest/examples-draganddrop.html), especially at the Draggable Icons Example (http://doc.qt.nokia.com/latest/draganddrop-draggableicons.html).

Hope this helps,
Wladek