QNetworkReplyWrapper Class
A wrapper around QNetworkReply and QNetworkAccessManager. More...
Header: | #include <qnetworkwrappertask.h> |
Inherits: | QObject |
Note: All functions in this class are reentrant.
Public Functions
QNetworkReplyWrapper(QObject *parent = nullptr) | |
virtual | ~QNetworkReplyWrapper() override |
QNetworkReply * | reply() const |
void | setData(const QByteArray &data) |
void | setNetworkAccessManager(QNetworkAccessManager *manager) |
void | setOperation(QNetworkAccessManager::Operation operation) |
void | setRequest(const QNetworkRequest &request) |
void | setVerb(const QByteArray &verb) |
void | start() |
Signals
void | done(QtTaskTree::DoneResult result) |
void | downloadProgress(qint64 bytesReceived, qint64 bytesTotal) |
void | sslErrors(const QList<QSslError> &errors) |
void | started() |
Detailed Description
QNetworkReplyWrapper is a convenient class combining QNetworkAccessManager and QNetworkReply.
The mandatory configuration is to call setNetworkAccessManager() and setRequest(). By default the QNetworkReplyWrapper is configured with QNetworkAccessManager::GetOperation. Use setOperation() to perform other operations. Use setData() when the configured operation is Put, Post or Custom. Use setVerb() when the configured operation is Custom.
The associated QNetworkReply may be accessed via reply() method. The QNetworkReply is created dynamically by the start() method and managed by QNetworkReplyWrapper. It is deleted just after emitting done() signal.
Member Function Documentation
QNetworkReplyWrapper::QNetworkReplyWrapper(QObject *parent = nullptr)
Creates QNetworkReplyWrapper with a given parent.
[override virtual noexcept]
QNetworkReplyWrapper::~QNetworkReplyWrapper()
Destroys the QNetworkReplyWrapper. If the accociated reply() is still running, it's aborted.
[signal]
void QNetworkReplyWrapper::done(QtTaskTree::DoneResult result)
This signal is emitted after the associated QNetworkReply finished. The passed result indicates whether it has finished with success or an error.
See also reply().
[signal]
void QNetworkReplyWrapper::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
This signal re-emitted from the running QNetworkReply, passing bytesReceived and bytesTotal.
See also reply().
QNetworkReply *QNetworkReplyWrapper::reply() const
Returns the pointer to the accociated QNetworkReply. Before the QNetworkReplyWrapper is started and after it's finished, this function returns nullptr. It's safe to access the QNetworkReply after the started() signal is emitted and until done() signal is emitted.
void QNetworkReplyWrapper::setData(const QByteArray &data)
Set the data to be used on start(). It's used only in case of QNetworkAccessManager::PutOperation, QNetworkAccessManager::PostOperation, or QNetworkAccessManager::CustomOperation.
void QNetworkReplyWrapper::setNetworkAccessManager(QNetworkAccessManager *manager)
Set the manager to be used on start().
void QNetworkReplyWrapper::setOperation(QNetworkAccessManager::Operation operation)
Set the operation to be used on start().
void QNetworkReplyWrapper::setRequest(const QNetworkRequest &request)
Set the request to be used on start().
void QNetworkReplyWrapper::setVerb(const QByteArray &verb)
Set the verb to be used on start(). It's used only in case of QNetworkAccessManager::CustomOperation.
[signal]
void QNetworkReplyWrapper::sslErrors(const QList<QSslError> &errors)
This signal re-emitted from the running QNetworkReply, passing a list of ssl errors.
See also reply().
void QNetworkReplyWrapper::start()
Starts the QNetworkReplyWrapper.
[signal]
void QNetworkReplyWrapper::started()
This signal is emitted after successful start of the managed QNetworkReply.
See also start().
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.