Hi,

have a look here :
http://developer.qt.nokia.com/doc/qt-4.8/model-view-programming.html#model-classes

AFAIR jambi breaks with the c++ in some points concerning the modelindex.
But the structure is still the same.

If I understand you correctly, you want to change the internat structure of
your "flat list", in a way that it is displayable in a tree model but still
use the original flat list.
For this have a look at Proxymodels. These support to transform the
internal model structure without changing the original model, think of them
as an additional adapting layer between the original model and the view.
http://developer.qt.nokia.com/doc/qt-4.8/model-view-programming.html#proxy-models

Regards

On Tue, Feb 7, 2012 at 8:41 PM, Josh Highley <joshhigh...@gmail.com> wrote:

> The Jambi tree examples that I've found use the file system as the model
> and relies on the filesystem to provide the parent-child relationship,
> which doesn't help me.
>
> I have a flat list of objects in a QAbstractItemModel.  I use this model
> with other views so I can't just extend QTreeModel instead.  For my tree
> view, I just want to use a property of each object to group the objects in
> a simple 2 level tree.  Based on the parameters passed to the abstract
> methods in QAbstractItemModel, I can't figure out how I can determine what
> the view is requesting.  By extending QDirModel and putting print
> statements in the data method, I found, for example, the (row,column) - aka
> QModelIndex - for the first level in the tree is (0,0), (1,0), (2,0), etc.
> If I choose one of those levels, then the children also have the same index
> rows and columns: (0,0), (1,0), (2,0).  So, in the method data(QModelIndex
> index, int role), how can I know what index is referring to?  Same goes for
> the parent(QModelIndex child) and rowCount(QModelIndex parent) methods.
> The parameters seem too vague to figure out exactly which tree item the
> view is requesting: one of the groups or one of the objects in the group.
>
> Thanks,
>
> Josh
>
> _______________________________________________
> Qt-jambi-interest mailing list
> Qt-jambi-interest@qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-jambi-interest
>
>
_______________________________________________
Qt-jambi-interest mailing list
Qt-jambi-interest@qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-jambi-interest

Reply via email to