[Interest] ProxyModel for background image download - How to notify sourceModel?
Philipp Kursawe
phil.kursawe at gmail.com
Thu Nov 28 15:00:09 CET 2013
I have a proxymodel that is responsible for background image downloading.
How to I notify the source model (which does not implement setData, doesn't
have to) that an image has been downloaded? My proxy keeps a cache of
downloaded images for every row in the source model
QVariant ProxyModel:data(index, role) {
if (role == Qt::DecorationRole) {
if (cache not contains(index)) {
startBackgroundDownload(QPersistentIndex(index));
return placeholderimage;
} else {
cachedImage;
}
}
}
void ProxyModel::onDownloadFinished(index) {
// how do I force the sourceModel to refresh?
emit
sourceModel->dataChanged(index, QVector<int>() << Qt::DecorationRole);
}
This works, but I know we should not call signals of other objects
directly. So how would that work otherwise? By connecting the ProxyModels
dataChanged signal to the sourceModel dataChanged signal?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131128/4d7ad3cd/attachment.html>
More information about the Interest
mailing list