Qt World Summit: Register Today!

Update non-editable QTableView with QAbstractTableModel

  • How to update QTableView when my model changes? My QTableView is non editable, so afaik i dont have/want to reimplement setData(...).
    How do i update it, after my internal data changes?

    class myTableModel : public QAbstractTableModel
    	void SetMyData(MyDataType* myData)
    		m_myData = myData;
    		emit QAbstractItemModel::dataChanged(index(0, 0), index(myData->rows(),myData->Cols()));

    Doesn't work, neither tableView->update() does.

    thanks for help

  • Lifetime Qt Champion


    Since you are replacing your underlying data, I'd rather go with modelReset

  • problem is that index(myData->rows(),myData->Cols())
    is not a valid index

    it should be
    if functions are named correctly

Log in to reply