Question

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?

Était-ce utile?

La solution

QTableView::model() returns whatever model you gave it with QTableView::setModel(), it doesn't have one until you give it one.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top