PDA

View Full Version : QAbstractItemModel Using External QList Examples



jeffpogo
12th July 2009, 14:42
What I need is something that is probably common, so I am hoping someone can post some example source code. (All the examples I found use an internal data source.)

1.) Create a class User with multiple fields (code, name, password, etc.)
2.) I want to create a QList of User objects -- m_UserList
3.) Create a class UserModel : public QAbstractItemModel
4.) Display the the User List in a QTreeView using the UserModel. (read only)

I want the QTreeView to change when I update, add, and remove items in the m_UserList.

The example I am looking is a QAbstractItemModel class using in an external QList of class objects.

Thank you, Jeff. :)

wysota
13th July 2009, 09:59
There is no generic model like that (although I have written a generator for such cases but I can't share the code) although it should be easy to provide a skeletal implementation of such a model.

jeffpogo
13th July 2009, 15:52
Yes, if you have time, please post a skeleton. I can see many uses for such a model, and I am sure others would benefit too. I will post my code -- If I come up with a working implementation. Thanks, Jeff.