本文整理汇总了C++中QNetworkAccessManager::cache方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkAccessManager::cache方法的具体用法?C++ QNetworkAccessManager::cache怎么用?C++ QNetworkAccessManager::cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkAccessManager
的用法示例。
在下文中一共展示了QNetworkAccessManager::cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cache
QNetworkDiskCache* FileServer::cache(const QString &cacheDir) {
QNetworkAccessManager *manager = networkAccessManager();
QNetworkDiskCache *dc = qobject_cast<QNetworkDiskCache*>(manager->cache());
if (!dc) {
dc = new QNetworkDiskCache(manager);
manager->setCache(dc);
}
if (m_replies.isEmpty()) {
dc->setCacheDirectory(cacheDir);
}
return dc;
}
示例2: willLoadFromCache
bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame* frame)
{
if (!frame)
return false;
QNetworkAccessManager* manager = QWebFramePrivate::kit(frame)->page()->networkAccessManager();
QAbstractNetworkCache* cache = manager->cache();
if (!cache)
return false;
QNetworkCacheMetaData data = cache->metaData(request.url());
if (data.isValid()) {
request.setCachePolicy(ReturnCacheDataDontLoad);
return true;
}
return false;
}
示例3: willLoadFromCache
bool ResourceHandle::willLoadFromCache(ResourceRequest& request, Frame* frame)
{
if (!frame)
return false;
QNetworkAccessManager* manager = 0;
QAbstractNetworkCache* cache = 0;
if (frame->loader()->networkingContext()) {
manager = frame->loader()->networkingContext()->networkAccessManager();
cache = manager->cache();
}
if (!cache)
return false;
QNetworkCacheMetaData data = cache->metaData(request.url());
if (data.isValid()) {
request.setCachePolicy(ReturnCacheDataDontLoad);
return true;
}
return false;
}