The code below (a very simple QTableView example) works fine under Qt4.2.3 but it does not work with Qt4.3.
No idea why. Any help is greatly appreciated.
Thanks
Chris
The code below (a very simple QTableView example) works fine under Qt4.2.3 but it does not work with Qt4.3.
No idea why. Any help is greatly appreciated.
Thanks
Chris
The problem is that you did not call beginInsertRows/endInsertRows.
You must call them before/after setModelData, in populate();
Be careful with the parameters for beginInsertRows.
Regards
Actually, the problem is somewhere else. Forget what I said before.
The docs say:
You were clearing the data and also reset the model before recreating the back store. This happens in function TableModel: populate.Resets the model to its original state in any attached views. When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again.
When a model radically changes its data it can sometimes be easier to just call this function rather than emit dataChanged() to inform other components when the underlying data source, or its structure, has changed.
The error was that when you called reset on the model, it tried to reinitialize with new data ( header views, etc ). But there was no new data, because it was created after you reset the model.
The solution is to call reset just after setModelData(), in populate.
This way the model will have an update source available.
Regards
ccf_h (17th June 2007)
Great, that worked!!! Thanks a lot. :-)
I still wonder why it worked under Qt4.2 and earlier. They seem to have changed a lot internally.
Bookmarks