문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top