Dear all,

I use a QTableView to display products information described with QStandardItemModel. I need to implement the feature to change row order via drag-and-drop. Here is the code:
.h file:
QTableView *tableView_allProducts.
QStandardItemModel *ensembleProductModel;

.cpp file:
ensembleProductModel = new QStandardItemModel(0, PRODUCT_COLUMN_COUNT);
tableView_allProducts->setModel(ensembleProductModel);
tableView_allProducts->setSelectionMode(QAbstractItemView::ExtendedSelec tion);
// When user select an item, the whole row is selected
tableView_allProducts->setSelectionBehavior(QAbstractItemView::SelectRow s);
// Implement the feature to change row order via drag-n-drop
tableView_allProducts->setDragEnabled(true);
tableView_allProducts->setDragDropMode(QAbstractItemView::InternalMove );
tableView_allProducts->setDropIndicatorShown(true);

The problem with the above code is that after the selected row is moved to the new position, an empty row with default values (zeros) remains at the original position. So there is one more row after drag-n-drop. What’s problem with my code? Thanks.

My development tools are Visual Studio 2008, Qt 4.8.3.