How to Drag and Drop Custom Widgets?
-
I have created my own custom widget and I want to support internal drag and drop for the widgets.
I have added 4 of my custom widgets in a vertical box layout. Now i want to drag and drop the custom widgets internally. To be more clear, If i drag the last widget and drop it in the first position, then the first widget has to move to the second positon and the last widget (which is dragged) has to move to first position. (same like drag and drop of the items in the List view). Can anyone suggest me a way to drag and drop of the custom widgets.
![IMG]http://i.imgur.com/TcZa11o.png[/IMG](Drag and Drop of Custom Widgets)!
-
The vertical box layout has to be changed after you drop the drag.
Keep track of every component index in a layout, reimplement dragEnterEvent() method in every widget as the other drags in. When dragging, using a pixmap as thumbnails when dragging like those in Chrome and Firefox is a good idea. -
Hi jiangcaiyang & Rochi, can you guyz please post an example of how to drag and drop the widgets. So that the newbie's will learn alot from that. Moreover, how to change the vertical box layout each and every time when the drop is done. can you please explain it with an example.
-
Something like this?
"dragDrop":http://qt-project.org/faq/answer/how_can_i_do_drag_and_drop_in_a_widget