[Interest] ProxyModel for background image download - How to notify sourceModel?

Tony Rietwyk tony at rightsoft.com.au
Thu Nov 28 15:20:43 CET 2013


Hi Philipp, 

 

If your view is attached to the proxy model, then you could just emit from the proxy itself.  

 

Regards, 

 

Tony

 

 

 

Sent: Friday, 29 November 2013 1:00 AM

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/20131129/4651c16a/attachment.html>


More information about the Interest mailing list