On 2007-11-09, Dirk Wagener wrote: > Hi > > I am experiencing some confusion regarding the model/view architecture > when using a QTreeView with a custom > QAbstractItemModel. [snip] > Can somebody please give me some advice. Where can I learn how to do > this model/view interaction properly? > Are there some rules which I am not obeying here??
I find it difficult to answer without seeing more code. However, some things are clear: - If you insert rows you _must_ do so in an insertRows() reimplementation and you _must_ call beginInsertRows() (with the correct arguments) before inserting, and endInsertRows() at the end. Similarly for removing rows. - You should never need to emit layout-related signals. Inside your setData() reimplementation you _must_ emit the dataChanged() signal (if data is actually changed); if you do lots of changes, then you should call QAbstractItemModel.reset()---this will tell any views that they must refresh all their visible data. Getting hierarchical models working is tricky. You might find more help in the C++ documentation: http://doc.trolltech.com/4.3/model-view-programming.html -- Mark Summerfield, Qtrac Ltd., www.qtrac.eu _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt