[Qt-interest] if i use QAbstractItemModel::beginMoveRows will selection track moved rows?
Ross Bencina
rossb-lists at audiomulch.com
Sun Jun 12 03:56:10 CEST 2011
Hi
I have some tables representing a sparse array. The tables allow elements to
be dragged between cells. I've just ported this to use the model-view
classes (previously I used QTableWidget).
I have drag and drop semantics somewhat like a list, where dragging an item
to an in-use row re-shuffles items between existing cells, to support
reordering in non-spares lists. For example:
BEFORE:
row
[1] item A
[2] item B
[3] item C
[4] item D
dragging item A to cell D moves all other items up like so:
AFTER:
row
[1] item B
[2] item C
[3] item D
[4] item A
My problem is that after the drag and drop operation, item A is no longer
selected because I am using emit dataChanged() in my model to invalidate the
rows. Question: if I instead used beginMoveRows()/endMoveRows() then would
the selection update correctly?
In any case, the above example is not a contiguous move since
source={1,2,3,4} and destination={4,1,2,3}. How can I deal with this? or
should I just hack my model to directly modify the selection after a
drag-and-drop operation?
Thanks
Ross.
More information about the Qt-interest-old
mailing list