You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, July 11th 2005, 12:21pm

How to make drag&drop in QListView

I have a problem making draging items in QListView... i want to drag them inside list to just change order... Any sugestion how to make it, what slots use etc?
GOD BLESS THE MANUALS AND FORUMS!

2

Monday, July 11th 2005, 1:49pm

RE: How to make drag&drop in QListView

Hello,

You have to set this parameters :

setDragEnabled(true);
setAcceptDrops(true);


You should also set your items enabled for drag&drop

yourItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled)


With those parameters, it should be cool :)
Guilugi

This post has been edited 1 times, last edit by "gferry" (Jul 11th 2005, 1:50pm)


3

Monday, July 11th 2005, 7:13pm

Thanks for help... but it doesnt work... is it from QT4?
GOD BLESS THE MANUALS AND FORUMS!

4

Tuesday, July 12th 2005, 9:53am

Yes, it's Qt4 code... your project is made with Qt3 ?

5

Tuesday, July 12th 2005, 5:31pm

Yes but now im porting it to QT4... And this code will be enough to make Drag'n'Drop? Or i'll have to write some slots?
GOD BLESS THE MANUALS AND FORUMS!

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

6

Tuesday, July 12th 2005, 9:07pm

You have to implement handlers which will be executed when an item is dropped. See docs for details and examples.

7

Thursday, July 14th 2005, 10:47pm

I've decided to make drag and drop in QTreeWidget... What do i need to do to implement Drag'n'Drop inside the treewidget (i need it only to change items order). Any sugestion? I dont know if im right, but i think i should promote it to custom widget and reimplement itemPressed slot, add mouseMoveEvent... Correct me if im wrong

EDIT:
I've enabled draging and droping at widget, and drag'n'drop works but it copy draged items. Also i want to disable childs to all items.

EDIT:
I've made items with no childs by setting the identation to 0... the only problem is the copying now... Anyone knows where to set default drop action?
GOD BLESS THE MANUALS AND FORUMS!

This post has been edited 3 times, last edit by "naresh" (Jul 15th 2005, 12:27am)