PDA

View Full Version : QTableView / QAbstractItemView Dragging rows internally



schapman1974
7th May 2013, 17:41
I have subclassed the QAbstractItemView as the model for my qtableview. And I want to add the ability to move
rows around in the Table. I did setMovable and it does allow me to move the rows. I also have multiselect activated
on the tableview so I can select multiple rows.

However I have no way of moving multiple rows. I would like to be able to select multiple rows using the ctrl key
and then have the mousemove event move the selected rows up or down.

I have searched for a solution to this and thus far the only two things that seem to make sense is that possibly
in a different selection mode I could possibly make the drag feature work. Or I would need to reimplement
the mousepress and the mousemove events in my table.

I am not sure what will work and what to put in the reimplemented events if that were what I needed to do.

Thank you

Santosh Reddy
10th May 2013, 16:44
I have searched for a solution to this and thus far the only two things that seem to make sense is that possibly
in a different selection mode I could possibly make the drag feature work. Or I would need to reimplement
the mousepress and the mousemove events in my table.

I am not sure what will work and what to put in the reimplemented events if that were what I needed to do.
I don't think muli-selection drag & drop results can be defined in general terms for a wide range of usage, and hence are not possible with generic itemViews.

And yes you have already figured out the possible solutions, those are your options.