[Qt-interest] Qt MVC Questions

Willy P willy.lists at gmail.com
Sat Sep 19 03:02:34 CEST 2009


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.

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.

Possible solution to #1, I could set a delegate for an "invisible" row
and have it return a sizeHint of 0,0.  Seems like a hack but it may
work.

Any other thoughts on these?

Thanks in advance...

-Willy



More information about the Qt-interest-old mailing list