How to reload the tableview to reload its data ?



  • Hi i retrieve data from a data base with a model and then it is displayed with a tableview.
    i have a button witch delete the selected row from the tableview. When i click on it, the row is deleted from the database but no from the tableview. So witch function can i use to reload the data in the tableview?



  • If you are using QSqlQueryModel you should re-set its query using setQuery.
    There isn't any function to 'refresh' a QSqlQueryModel.



  • actually i use QSqlTableModel. To refresh the tableview i did @model->select();
    ui->tableView1->setModel(model);@ and it works thanks :)



  • The call to select does the trick alone.

    Calling setModel() with the same model as before is a no-op anyways :-)

    @
    void QAbstractItemView::setModel(QAbstractItemModel *model)
    {
    Q_D(QAbstractItemView);
    if (model == d->model)
    return;
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.