[Qt-interest] Qt MVC Questions
Sean Harmer
sean.harmer at maps-technology.com
Sun Sep 20 13:21:29 CEST 2009
Willy P wrote:
> I have built a Model, a view and a delegate that represents a tree
> like data structure.
>
> Two related questions:
>
> 1) Is there a way to hide TreeNodes in a view but show their
> children? Basically I have data structures that are programatically
> useful but the user doesn't need to know about them. So I'd like the
> view to show the invisible node's children as if they were children of
> the invisible node's parent. I've tried setRowHidden() but it hides
> all the children as well.
>
Try a custom class derived from QProxySortFilterModel.
> 2) The opposite question. Is there a way to have nodes appear in the
> view but not the model? I basically want to add categorical
> separators. In some situations I want them and in others I don't, but
> in no case do I need them in the raw model.
>
Once again a custom proxy that sits between your source model and your
custom view(s) will be the way to go. I think that there is already some
classes in KDE that do this. Yes, check out KCategorizedView and
KCategorizedSortFilterProxyModel:
http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKCategorizedView.html
http://api.kde.org/4.x-api/kdelibs-apidocs/kdeui/html/classKCategorizedSortFilterProxyModel.html
They should do what you need for (2) without any work needed on your part.
Sean
More information about the Qt-interest-old
mailing list