PDA

View Full Version : Changing the view refresh policy when dealing with a fast changing model



schall_l
10th August 2009, 08:54
I have a view displaying the items of a fast changing model.
Sometimes the view cannot keep up with displaying new data making the GUI less responsive.
So I would like to know if there is a way to change the displaying policy of the view, f.e. making the view to refresh it content on a timer event.

wagmare
10th August 2009, 09:09
items of a fast changing model.

may be it takes lonk time to return scene()->update() ...

if there is any long running (algorithm/formula/calculation) for the items try to port it to QThread() or use qApp->processEvents();

also check ..

setViewportUpdateMode(FullViewportUpdate); // to your area ..

faldzip
10th August 2009, 09:45
in the QAbstractItemView in setModel() method some connections are set:


connect(d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
this, SLOT(dataChanged(QModelIndex,QModelIndex)));
connect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(rowsInserted(QModelIndex,int,int)));
connect(d->model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));

What I would try is to disconnect those connections, connect rowsInserted() and dataChanged() to my own slot to collect changed/inserted rows, and then in some slot called on QTimer timeout() just simply call proper slot in the view, and clear own changed/inserted collection.
Didn't tested and I am not sure if it is the best way.
P.S. those slots are protected members in QAbstractItemView so you have to subclass the view you are using.