You need to remplement mouse events and rendering-related methods (which in practice makes up most if not all of the view code).
You need to remplement mouse events and rendering-related methods (which in practice makes up most if not all of the view code).
In very simple case, in current default implementation, to implement row moving inside one table,
what is the best approach with functions removeRows and insertRows?
Could I use them directly one after another inside dropMimeData?
So I can pack in MIME number of line of dragged item and inside dropMimeData I retrieve number of drop line.
I would say it is better to use QAbstractItemModel::beginMoveRows() and QAbstractItemModel::endMoveRows() in this case. In a general case dropMimeData() would only insert rows and rows removal would be done in the code when the drag is started when a "move" operation is detected.
I'm not clearly understand what do you mean.
generally I didn't get what sense of QAbstractItemModel::beginMoveRows() and QAbstractItemModel::endMoveRows()
By docs I should use them from removeRows, like
bool TableModel::removeRows(int position, int rows, const QModelIndex& index)
{
Q_UNUSED(index);
beginRemoveRows(QModelIndex(), position, position + rows - 1);
endRemoveRows();
return true;
}
But dragging begins from const func mimeData, where I can't call non const method.
Where that place you have mentioned?and rows removal would be done in the code when the drag is started when a "move" operation is detected.
Last edited by Nickolay; 19th September 2011 at 20:37.
I suggest you read a little about model-view framework in Qt. Everything should become clearer then. One hint -- drag and drop in Qt is handled in the model and not in the view.
Bookmarks