Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, March 2008
Custom Tree Model - some slow-downs take place


Message 1 in thread

Hello,
I have a problem with a custom made tree-model and the view that is
showing the data.

What I do is this:
based on the sample provided of how to build a tree model, I have made
my own classes.
Now, my model is a readonly model and is changed at runtime by some
worker threads by adding more rows to different sub-branches, and also
they update some data in columns. The update is happening by means of
signals and it is happening very often.

1. If a new row is added to the model, how to inform the view update
only for one row ?
- emit dataChnaged(index,index) is not working, the new row is not
even shown in the view;
- emit layoutChanged() is slow since in case of lots of data in the
model - all the data from the model has to be reread each time;
- reset() - the same as emit layoutChanged();

2. because I do the model update from threads using signals, this puts
a big overhead on the CPU, and the UI becomes unresponsible. This is
also due to the issue described in (1) because at each new line to be
added I call reset() or emit layoutChanged() - this becomes very dead
even with less than 50 lines in the model.

Ideas ?


Just a notice: build a simple app with over a 100 lines in a tree
model, attach a view to it, and try to click around on the lines -
only this process alone of clicking takes some CPU and not so fast
feed back from UI.   ---  Is this only me or this is how models are
supposed to work ?

--
 [ signature omitted ] 

Message 2 in thread

> - emit dataChnaged(index,index) is not working, the new row is not
> even shown in the view;
Emit dataChanged( inidex, QModelIndex( index.row()+1, index.column() )

Essentially, I have found the range to not be inclusive

Scott


Message 3 in thread

On Monday 10 March 2008 01:17:52 Yong wrote:
> Hello,
> I have a problem with a custom made tree-model and the view that is
> showing the data.
>
> What I do is this:
> based on the sample provided of how to build a tree model, I have made
> my own classes.
> Now, my model is a readonly model and is changed at runtime by some
> worker threads by adding more rows to different sub-branches, and also
> they update some data in columns. The update is happening by means of
> signals and it is happening very often.
>
> 1. If a new row is added to the model, how to inform the view update
> only for one row ?
> - emit dataChnaged(index,index) is not working, the new row is not
> even shown in the view;
> - emit layoutChanged() is slow since in case of lots of data in the
> model - all the data from the model has to be reread each time;
> - reset() - the same as emit layoutChanged();

You want to use beginInsertRows(...) and  endInsertRows() to insert one row.  
When this is done the view will insert one row without re-reading the entire 
tree.

-Benjamin Meyer

--
 [ signature omitted ]