Hello all together,
currently I'm just learning programming with Qt. Today I found a problem that I cannot solve by myself
I have an (empty) QStandardItemModel that is shown with a QTableView. After the user did something, I want to fill the model with some data, that means I want to change it (e.g. add some more rows or set new data). Because I don't have the pointer to the model itself anymore, I want to get the pointer out of the TableView:
QStandardItemModel* model=myTable->model();
Now I only get a pointer with type QAbstractItemModel, which is an abstract class and misses some members of QStandardItemView. Casting it to QStandardItemView* seems to work: QStandardItemModel* model=(QStandardItemView*)myTable->model();
But now my program crashes with a segmentation fault on every call like
QModelIndex index=model->index(0, 0, QModelIndex());
or
model->insertRows(0, Count(), QModelIndex());
What am I doing wrong? Is the crash related to the cast or to the invalid QModelIndex?
Thank you for help,
thw
Bookmarks