PDA

View Full Version : Blocking updates on views



NoRulez
29th April 2010, 08:51
Hi,

is there a way to block all updates on a view (e.g. TableView). I want to update the views only if I emit signal.

Did anybody know a way how i can do this?

Best Regards
NoRulez

wysota
29th April 2010, 09:26
There is a property available - QWidget::updatesEnabled but be sure you know what you are doing.

NoRulez
29th April 2010, 11:17
Thank you very much, this seems to solve my problem.

Best Regards
NoRulez

NoRulez
30th April 2010, 11:58
Ok, it doesn't solve the problem, which means that the gui is still blocking.

I've attached a small example which demonstrate the problem.

I hope someone could help.

Best Regards
NoRulez

tbscope
30th April 2010, 12:35
Do not show all your data at once, use fetchmore.
http://doc.qt.nokia.com/4.6/itemviews-fetchmore.html

Do your data parsing or loading in a thread or asynchronous and use that data to populate your model. Use fetchmore to prevent blocking.

Edit: To be more clear: in your thread you have this line: m_pModel->insertRows(m_pModel->rowCount(), 1);
Leave adding rows to the model, not your thread. Create a custom model, keep a list of data inside the model and add data to that list via your thread (signals will work very well for this). Then, when you scroll in your view, the model will check if there's more data to display and adds the next few rows.

wysota
4th May 2010, 20:28
QObject subclasses are not thread-safe, don't try accessing the model directly from a worker thread or this will lead to trouble. Use signals and slots instead. And update your model in chunks, not a row at a time.