Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_network_access_qnetworkdiskcache.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
8 + QLatin1StringView("/cacheDir/");
12
14using namespace Qt::StringLiterals;
15// do a normal request (preferred from network, as this is the default)
16QNetworkRequest request(QUrl(u"http://qt-project.org"_s));
18
19// do a request preferred from cache
20QNetworkRequest request2(QUrl(u"http://qt-project.org"_s));
24
28 qDebug() << "page from cache?" << fromCache.toBool();
29}
The QNetworkAccessManager class allows the application to send network requests and receive replies.
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
void setCache(QAbstractNetworkCache *cache)
The QNetworkDiskCache class provides a very basic disk cache.
void setCacheDirectory(const QString &cacheDir)
Sets the directory where cached files will be stored to cacheDir.
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
QVariant attribute(QNetworkRequest::Attribute code) const
Returns the attribute associated with the code code.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
void setAttribute(Attribute code, const QVariant &value)
Sets the attribute associated with code code to be value value.
static QString writableLocation(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
#define qDebug
[1]
Definition qlogging.h:164
QNetworkReply * reply
QNetworkRequest request2(QUrl(u"http://qt-project.org"_s))
QNetworkAccessManager * manager
[0]
QNetworkRequest request(QUrl(u"http://qt-project.org"_s))
void replyFinished(QNetworkReply *reply)
[1]
QNetworkDiskCache * diskCache