PDA

View Full Version : Draggable Button



blueescort
4th November 2008, 14:44
Hello,

I'm searching for a possibility to drag'n'drop buttons, just as it is possible in QtDesigner.
What I want is, that on running the application someone can reorder buttons in a way he want. Maybe there is someone, who performed so.
I'm just working with Qt for 2 weeks. Maybe there is a functionality I've overlooked.
Thanks for help.

Mirko

fnmblot
4th November 2008, 16:57
http://doc.trolltech.com/4.4/draganddrop-draggableicons.html This should be about the same as what you are asking for, right?

blueescort
5th November 2008, 09:30
Yes, thanks, thats what I'm looking for.
Now I tried to change the QLabel to QPushButton but it doesn't work. I get a button on a new widget, not on the main widget. Maybe I'm doing wrong something with the MimeData. Or do I have to write my own moveButton instead?

blueescort
5th November 2008, 10:31
Now I'm having the Button on the widget. But it won't move. I've changed the mousePressEvent, but just don't know, what MimeData I've got to drag and drop. Anybody some ideas?

aamer4yu
6th November 2008, 07:36
I guess you will need custom buttons to be able to move it.
You have left side and right side. On left side u have buttons with drag enabled logic. On right you have Widget which acts like a drop site, and with the mime data creates a MyPushButton. This MyPushButton is coded to move on mouse move events.

You can see Shaped Clock example in Qt Demos-> Widgets to how to move a widget.
Hope this helps :)