Changing the view refresh policy when dealing with a fast changing model
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.
Re: Changing the view refresh policy when dealing with a fast changing model
Quote:
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 ..
Code:
setViewportUpdateMode(FullViewportUpdate); // to your area ..
Re: Changing the view refresh policy when dealing with a fast changing model
in the QAbstractItemView in setModel() method some connections are set:
Code:
connect(d
->model,
SIGNAL(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.