Qt-interest Archive, April 2008
[model/view] Free item view layout
Message 1 in thread
Hi list,
I'm trying to understand the model/view framework and I have some
trouble designing my application.
The application consists in a white sheet where the user can freely
organize rectangle widgets/items showing key/value pairs
The application consists in a white sheet where the user can freely
organize rectangles showing key/value pairs. Think about a diagram
application like dia or inkskape.
At the moment, my model is a table of two columns: the first one for
the key and the second one for the value.
I think, I am right to do that, no?
Implementing the view (inheriting from QAbstractItemView), leads me to troubles:
- One item of my view display two items of my model (the key in column
0 and the associated value in column 1), so I'm wondering whether I
should have a list model (rather than a table model) with the value as
a role.
- Since the items of my view may be moved around by the user, I have
to store their coordinates in the model by probably adding two more
columns (or adding one role??). But, these informations are dependent
of my view, so I'm wondering whether the model is the right place to
store them. Up to now, I have only seen views displaying items in a
"fixed" way (e.g. the item is displayed based on its row/column
coordinate in the model).
I hope I have been clear enough.
Cheers,
--
[ signature omitted ]