qlistview drag&drop problem
Hello, I have a problem with a qlistview. I have some custom made slides in it and I have a problem with dragging them around qlistview. I enabled the drag&drop on the qlistview like this:
Code:
//just for reference
//QListView *iconList;
iconList->setDragEnabled(true);
iconList->setIconSize(siz);
//iconList->setSelectionMode(QAbstractItemView::SingleSelection);
iconList->setGridSize(isiz);
iconList->setSpacing(inc_size);
iconList->setUniformItemSizes(true);
//iconList->setMovement(QListView::Snap);
iconList->setAcceptDrops(true);
iconList->setDropIndicatorShown(true);
If i start dragging from the top item it shows the marker but it's in the top left position. If i continue dragging (and move outside the widget area and than back -still dragging), the marker appears at the right position and stays that way until i realease the item All of the following dragging continued by the previous dragging is made completely ok (the marker is right where it should be.
Does anyone have any idea??
ps. I use this for the drag events... ( if I use qlistview events the result is absolutely awfull...)
Code:
//QListView::dropEvent(event);
}
//QListView::dragMoveEvent(event);
}
Re: qlistview drag&drop problem
Hmm, sounds like you are mixing two things up; 1) moving items around the list view and 2) drag'n'drop. You don't need drag'n' drop for moving items around the list view:
Code:
#include <QtGui>
int main(int argc, char *argv[])
{
list.
setGridSize(QSize(20,
20));
list.setModel(&model);
list.show();
return a.exec();
}
Re: qlistview drag&drop problem
I'm not sure what did u try to achieve with you're test program (i compiled it and the movement doesn't work), but u we're right. I did confuse drag&drop and movement. But I still need both (to move files between different tabs). The problem is still the same (untill I move one element outside the widget I get the movement marker at the wrong place).
Re: qlistview drag&drop problem
Heh, it indeed doesn't seem to work with 4.1.4 whereas the movement works fine in 4.2.0. :)
But there you see how important it is to describe the actual problem.. So the problem was not moving items within a list view, the problem was with drag'n'dropping items between two different list views, right?
Re: qlistview drag&drop problem
I'll try to upgrade ... :) You're right, it is vital to address the problem properly. But the problem is the same. The problem is with the actual movement within the same listview and not with the drag&drop. Do you have any ideas how to fix this?
Re: qlistview drag&drop problem
Do you think that I have something wrong with my flags.. ?
Code:
Qt
::ItemFlags MyClass
::flags(const QModelIndex &index
) const{
if (index.isValid())
return Qt::ItemIsEnabled | Qt::ItemIsSelectable
| Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled;
return Qt::ItemIsEnabled | Qt::ItemIsDropEnabled;/*| Qt::ItemIsSelectable;*/
}
or with the way I initialize qlistviews gridsize:
Code:
QSize siz
= whiteboard
->size;
iconList->setIconSize(siz);
iconList->setGridSize(isiz);
iconList->setSpacing(inc_size);
iconList->setUniformItemSizes(true);
Re: qlistview drag&drop problem
Ok. I have 1t 4.2.0 up and running. My question still remains: is there any way to draw some kind of marker where the item is being moved while in movement (beside the plus) ??
Re: qlistview drag&drop problem
Qt 4.2.0 is absolutely terrible. It isn't ready for the release yet. So my question is next: is there any way to draw something to indicate where the item is being moved inside a qlistview ( like a line or a box maybe ) ??
Re: qlistview drag&drop problem
Ok. This thread is turning into a monologe. If anyone can help me I have my latest conclusion on the qlistview movement problem.... Ok I found out that the moving marker is shown for every slide as long as it is inside parent widgets viewport area.
Example:
i have 200*400 wide area and the area is abstractscrollarea so it can be bigger than the 200*400 and i just scroll to the right slide. here's the trick, if i move outside 200*400 area (scroll down) the moving marker stops showing and i have nothing showing for the movement.
Does anyone have any idea??