I think I've managed to make this work, but not quite how I originally intended. My code now looks something like this:
class MyModel {
MyModel();
...
slots:
void EndResetModel();
...
void MyModel::HandleSource2Data(const DataItem& item)
...
}
MyModel::MyModel()
{
...
source2Timer = new QTimer(this);
source2Timer->setInterval(500);
source2Timer->setSingleShot(true);
connect(source2Timer, SIGNAL(timeout()), this, SLOT(EndResetModel()));
}
void MyModel::EndResetModel()
{
endResetModel();
}
void MyModel::HandleSource2Data(const DataItem& item)
{
beginResetModel();
source2Cache.Add(item);
source2Timer->start();
}
class MyModel {
MyModel();
...
slots:
void EndResetModel();
...
void MyModel::HandleSource2Data(const DataItem& item)
...
}
MyModel::MyModel()
{
...
source2Timer = new QTimer(this);
source2Timer->setInterval(500);
source2Timer->setSingleShot(true);
connect(source2Timer, SIGNAL(timeout()), this, SLOT(EndResetModel()));
}
void MyModel::EndResetModel()
{
endResetModel();
}
void MyModel::HandleSource2Data(const DataItem& item)
{
beginResetModel();
source2Cache.Add(item);
source2Timer->start();
}
To copy to clipboard, switch view to plain text mode
endResetModel() is not a slot, its just a protected function. So the timer can't call endResetModel() directly; it needs to call a custom slot that in turn calls endResetModel().
Bookmarks