Qt: Example of QAbstractItemModel implementation using QtSql (to use with QTreeView)
I'm looking for an example implementation of QAbstract开发者_运维问答ItemModel to use with QTreeView. The model should load data from QSqlQuery and should do it in a "lazy" way. In other words I only want to load records for nodes/parents that are open. And I'd like to see how to properly add and remove records from this model.
I tried to implement such model on my own but got a lot of different bugs Especialy when I started adding and removing rows.
If you know where I could find such example I would be very grateful.
Thanks :)
To help developping your model, you may be interested in ModelTest (http://developer.qt.nokia.com/wiki/Model_Test)
If I understand correctly, you will only have on child in each first level element.
-Row1
|_ Row1 columns
+Row2
+Row3
-Row4
|_Row4 columns
If so, I'll explain main steps and basic structure.
精彩评论