Solved QListView icons movement
-
I would like to forbid movement of icons in the view but dragging to other views should stay enabled. Is there a way to achieve this?
-
Hi
setAcceptDrops(false);
might do it.
Else DragDropMode set to DragOnly -
Hi,
sorry, I didn't mention it, but dropping to view should be enabled.
I have QListView attached to QFileSystemModel. I would like to drag&drop files from/to this view, but I I want to forbid moving of icons within the view only(changing their positions in view).possible solution could be: returns icon to its original position if it was dropped to the same view and it was not dropped to some element(I want overwrite file if it was dropped to other file or copy file to folder if it was dropped to folder)
-
@chabo said:
If you have override then dropEvent/dropEnter
you can check for the source of the event.
if event->source() == this then reject
else accept
Yes same as your idea, but just forbid the actual drop so
no need moving it back. -
Thank you very much.
void MyListView::dropEvent(QDropEvent * event) { if (event->source() != this || indexAt(event->pos()).isValid()) { QListView::dropEvent(event); } }