QtTaskTree::QNetworkReplyWrapper Class | Qt TaskTree | Qt 6.11.1
Description: A wrapper around QNetworkReply and QNetworkAccessManager.

- Qt 6.11
- Qt TaskTree
- C++ Classes
- QNetworkReplyWrapper
- Qt 6.11.1 Reference Documentation

# QtTaskTree::QNetworkReplyWrapper Class

class QtTaskTree::QNetworkReplyWrapper

A wrapper around QNetworkReply and QNetworkAccessManager. More...

Header: | `#include <qnetworkwrappertask.h>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS TaskTree)` `target_link_libraries(mytarget PRIVATE Qt6::TaskTree)`
qmake: | `QT += tasktree`
Since: | Qt 6.11
Inherits: | QObject

- List of all members, including inherited members

Note: All functions in this class are reentrant.

## Public Functions

| QNetworkReplyWrapper(QObject *parent)
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()

## Reimplemented Protected Functions

virtual bool | event(QEvent *event) override

## 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

### `[explicit]` QNetworkReplyWrapper::QNetworkReplyWrapper(QObject *parent)

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().

### `[override virtual protected]` bool QNetworkReplyWrapper::event(QEvent *event)

Reimplements: QObject::event(QEvent *e).

### 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().