[Interest] Make a flat Model from a hierarchical Model with all children

Andre Somers andre at familiesomers.nl
Wed Mar 28 08:34:14 CEST 2012


Op 28-3-2012 8:20, Bo Thorsen schreef:
> Den 27-03-2012 14:01, André Somers skrev:
>> Op 26-3-2012 18:34, j-p.nurmi at nokia.com schreef:
>>>> I have a hierarchical Model and i want to have a flat Model.
>>>>
>>>> Does anyone have an idea on how to do this with an proxy model?
>>>>
>>> Try this:http://www.fioniasoftware.dk/blog/?p=51
>>>
>> Interesting. Not sure why he (Bo) didn't just replace the view with a
>> QTreeView though? Seems simpler...
>
> Hehe, you're missing the next level - the view classes are not the 
> only ones that can use the models :) I use this to choose items in a 
> tree model with a combo box.
>
> QComboBox can take a model to deliver the items in it. But tree models 
> have parents and usually multiple columns. The flat proxy can make a 
> single item with the text of each item based on several columns.
No, I got that part. My point was (or was supposed to be) that QComboBox 
can also display a tree directly, if you use it's setView method and set 
a tree view there. For easy use, you'd only need to confine the tree to 
a single column, but the parent/child relationship does not need to be 
removed for that.

André




More information about the Interest mailing list