Important: Please read the Qt Code of Conduct -

QAbstractItemModel::beginMoveRows 2 times or how to implement swapping in DataModel?

  • Hello. I have DataModel which inherits QAbstractItemModel with Tree data structure.
    I have a method QAbstractItemModel::moveRows which swaps source and destination rows in case if they are one right after another (i.e. rows 5 and 6), but QAbstractItemModel::beginMoveRows can process only one source row at a time. So in case with swapping I move 2 rows simultaneously. So, how can I make swap (moves) right way?
    p.s. Details of my implementation does not allow to detach one move from another.

  • Maybe I am misunderstanding, but isn't "swapping" 5 and 6 the same as moving row 6 before 5? No need to move 5?

Log in to reply