Get the actual row number of tableview after drag and drop
-
At first, the data of the tableview are
1 : apple
2 : pie
3 : bananaAfter drag and drop((only drag and drop on itself)) the item on the tableview, the data of the tableview are
3 : banana
2 : pie
1 : applebut when I want to iterate the item of the model one by one
codes
@for(int i = 0; i != rowCount(); ++i){
if(item(row, Fruit)){
return item(row, Fruit)->data(Qt::DisplayRole).value<QString>();
}
}@it print the data as
1 : apple
2 : pie
3 : bananaexpected result
3 : banana
2 : pie
1 : appleHow could I get the "actual" number after drag and drop?
The easiest solution I can think of is create one more column to store the row number of the model, then override the dropEvent, update the row number when the user drop their row.Any easier way to do it?