Nominate our 2022 Qt Champions!

Refresh the QTableview

  • I have A QWidget which is split in two parts (QTreeWidget at left and QTableView) at right ..

    For each row the selected at the left , the QtableView should get updated . Could you please let me know how should I get refresh the QTableView from code , when I select any row in QTreeWidget

    // handle tree row select and fill the Error Tabel at the right
    268 void MyView::TreeSelectionChanged()
    269 {
    270 const QModelIndex index = d_TreeWidget->selectionModel()->currentIndex();
    271 QString selectedText =;
    272 UString rowString(selectedText.toUtf8().constData());
    273 updateTable(rowString);
    274 }

    / method called to update error table when each of error type is selected in the treewidget
    259 void MyView::updateTable(UString& errorNameString) {
    260 My questions is what should be done to refresh the QTableView

    Please note , When I click the tableView header the view gets updated

  • If I understand correctly are you facing a problem that the viewport() is not updated ? if yes then you can call tableview->viewport()->update();

Log in to reply