Caching Data



  • hello :)
    i'm using QNetworkAccessManager to get web service data
    i want to cache the recieved data so that when there is no connection i got the data from cache
    @
    QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
    diskCache->setCacheDirectory("cacheDir");
    manager->setCache(diskCache);
    QNetworkRequest req(url);
    req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
    @

    it get what has been cashed before and don't look 2 the server
    so i change this attribute 2 be
    @
    req.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
    @
    but when there is no connection it got no data
    what can i do???
    by the way how i specify the path it will save data on the mobile?
    @
    diskCache->setCacheDirectory("cacheDir");
    @
    is this line create directory on project path??
    thanks in advance for your help :)


  • Moderators

    I added @ formatting tags to your code. Please be sure and use them in the future.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.