View Full Version : Anyway of updating a QTableView when model signals turned off?
steg90
16th May 2007, 10:11
Hi,
When I block signals on my model which my tableview uses it is so much faster at updating, but it only updates if I click on the tableview ( repaint ). Was wondering if there is a way to update the view without having to do this?
Regards,
Steve
wysota
16th May 2007, 10:20
Unblock signals on time and emit layoutChanged() or reset the model. Or better yet - insert all items at once into the model.
steg90
16th May 2007, 10:23
Hi,
What do you mean by unblock signals on time? This after something is inserted? Unfortunately, the data in the model is continuously updated, so I guess I can't insert all items at once?
Regards,
Steve
wysota
16th May 2007, 10:25
There is no such thing as "continously". You can update the model every second or so with all items gathered through that time. I'm sure your users won't mind a small lag.
steg90
16th May 2007, 10:32
Thanks,
I am updating the model every 5 milliseconds, the model is preloaded with data and certain parts of this data is updated ( such as reading signal from a car for the rpm ).
This is the code I have now which is called every 5 milliseconds :
void DACanTreeModel::updateTable( QString strData, QString strId )
{
QList<QObject*> *pList = theApp->m_dcb.GetSignalList();
if( pList )
{
for( int i = 0; i < pList->count(); i++ )
{
CDADcb::CSignal* pSignal = (CDADcb::CSignal*)pList->at(i);
// This signal belong to this CAN id, there can be many signals that do
if( pSignal->m_strId == strId )
{
// we need to do the conversion here - TODO
pSignal->m_strRawData = strData;
pSignal->m_nCount++;
}
}
emit layoutChanged();
}
}
wysota
16th May 2007, 11:03
Change 5 miliseconds to 500 miliseconds. 5ms i 1/200 of a second - human eye can't distinguish anything that's shorter than 0.05s (50ms). And don't block signals, it's not required in this situation.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.