When it´s necessary manipulate a model of a TableView, it's necessary to get this model using the function tableView->model()
. But, this returns a pointer to an QAbstractItem
, and it's necessary one to a QAbstractModel
.
So... I convert, using a dynamic cast, as shown bellow:
QStandardItemModel* model = dynamic_cast <QStandardItemModel*>
(mWidgets->tableView->model());
But, this pointer returns NULL and I can't find out why.
Is there some initialization necessary?
QTableView::model()
returns whatever model you gave it with QTableView::setModel()
, it doesn't have one until you give it one.