I want to use Qt to provide a graphical interface to a collection of user defined objects. For example I may have the following python class
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
and a linked list of instances
people = [Person('John', 60), Person('Laura', 33)]
I now want to use Qt to present a browsable list of the elements in people
. Perhaps I want to allow certain information to be displayed in various text boxes when the user clicks on the names of people in this list.
The Qt documentation contains the example of an address book which is pretty good match to my own case, but there are two crucial things missing from this tutorial
- In the address book tutorial the actual data (which in this case are the addresses of various persons) is stored in a QMap. Each name and address is represented as a QString. The QMap maps names to addresses. This is fine for that simple example, but I want to wrap a Qt interface around my own data. How is this done?
- The address book does not show how to display a list of existing address book entries.
I think the notion of the model/view architecture is relevant to this so I have read the model/view documentation. This documentation seems to strongly emphasize the use of Qt built-in container classes. This is fine but in the end I want to wrap this around my own data structures and I have not found a an explanation of how to do this.
QUESTIONS:
- How do I write code to expose my own pre-existing data through a Qt list or other graphical interface?
- The documentation on the model/view system is really confusing. How does Qt expect the data and associated viewable classes to be organized?
I am dedicated to understanding this and improving the documentation for others. If this thread attracts attention and useful information I will attempt to have it properly archived on the Qt webpage.
Thank you