Qt World Summit: Submit your Presentation

QTableView drag-n-drop to change order, empty row left

  • 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);
    // When user select an item, the whole row is selected
    // Implement the feature to change row order via drag-n-drop
    // TODO: this feature is not done right yet

    The problem with the above code is that after the selected row is moved to the new position, an empty row 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.

Log in to reply