[Qt-interest] QTreeView and custom QAbstractItemModel performance problem

Andre Somers andre at familiesomers.nl
Fri Jul 9 17:19:26 CEST 2010


On 9-7-2010 17:05, Felix Brack wrote:
> On 09.07.2010 15:55, Mandeep Sandhu wrote:
>    
>>> For what I want the TableView is like taking sledgehammer to crack a
>>> nut. I just want a protocol, say 200 lines, first column shows an icon
>>> and when it's full the oldest data gets discarded.
>>>        
>> Sorry for jumping in so late. I've been following your issue for some time.
>>
>> Initially you had mentioned "...i.e. the model is not hierarchic, all
>> rows have the same parent (root) and consist of multiple
>> columns..."
>>
>> In such a case, why did you choose to go for a tree based model and view combo?
>>
>> If there is no hierarchy in your data (i.e it's flat) wouldn't it be
>> easy for you to "flat" model/view combo? (Table model/view as
>> Sean/Andre suggested)
>>
>> I was initially confused thinking you had a tabular data for each
>> _level_ in your hierarchy and thats why you were using a tree
>> structure. But I guess thats not the case with you.
>>
>> Regards,
>> -mandeep
>>      
> What I was really looking for is a 'multi column list view' which does
> not exists in Qt except the TableView of course. I already tried to
> explain why I did not use a TableView from beginning. But this might
> need a better explanation.
> While looking for my 'multi column list view' in Qt's help a came across
> QListView. The help says:
>
> 'This view does not display horizontal or vertical headers; to display a
> list of items with a horizontal header, use QTreeView instead'
>
> Well, I decided to do so. If one really just wants a list view with a
> horizontal header it would perhaps be better to suggest:
>
> 'This view does not display horizontal or vertical headers; to display a
> list of items with a horizontal header, use QTableView instead'
>
> I don't blame the folks who wrote the excellent help, far from it! There
> are not many frameworks with such an outstanding documentation. Looking
> at the sentence above: my bee there is a tiny little bit of tuning
> required? Would be nice for dumb (a hard word I know, but I am talking
> about myself here;)) people like me.
>
>    
I think you are right.
Point is, that to display a pleasantly looking list, you need less lines 
of code with QTreeView than you do with QTableView, because QTableView 
by default looks more like an excel sheet than like a multi-columned 
list. You need to changes some settings to make it look pretty. Perhaps 
that's why that line is still in? Or maybe it is a Qt3 leftover? Perhaps 
you should file a bug report.

André

-- 
Nokia Certified Qt Developer.
Interested in Qt related job offers or freelance Qt consulting work.




More information about the Qt-interest-old mailing list