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_qrestaccessmanager.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
7 // The reply may be wrapped in the finish handler:
8 QRestReply restReply(reply);
9 if (restReply.isSuccess())
10 // ...
11});
13
14
16// With lambda
18 if (reply.isSuccess()) {
19 // ...
20 }
21});
22// With member function
23manager->get(request, this, &MyClass::handleFinished);
25
26
29// ...
31 if (!reply.isSuccess()) {
32 // ...
33 }
34 if (std::optional json = reply.readJson()) {
35 // use *json
36 }
37});
39
40
43 if (!reply.isSuccess())
44 // handle error
45 if (std::optional json = reply.readJson())
46 // use *json
47});
49
50
52manager->get(request, myData, this, [this](QRestReply &reply) {
53 if (reply.isSuccess())
54 // ...
55});
57
58
60manager->post(request, myData, this, [this](QRestReply &reply) {
61 if (reply.isSuccess())
62 // ...
63});
65
66
68manager->put(request, myData, this, [this](QRestReply &reply) {
69 if (reply.isSuccess())
70 // ...
71});
73
74
77 if (reply.isSuccess())
78 // ...
79});
81
82
85 if (reply.isSuccess())
86 // ...
87});
89
90
92manager->sendCustomRequest(request, "MYMETHOD", myData, this, [this](QRestReply &reply) {
93 if (reply.isSuccess())
94 // ...
95});
97
98
100manager->patch(request, myData, this, [this](QRestReply &reply) {
101 if (reply.isSuccess())
102 // ...
103});
\inmodule QtCore\reentrant
QNetworkReply * put(const QNetworkRequest &request, QIODevice *data)
Uploads the contents of data to the destination request and returns a new QNetworkReply object that w...
QNetworkReply * head(const QNetworkRequest &request)
Posts a request to obtain the network headers for request and returns a new QNetworkReply object whic...
QNetworkReply * post(const QNetworkRequest &request, QIODevice *data)
Sends an HTTP POST request to the destination specified by request and returns a new QNetworkReply ob...
QNetworkReply * get(const QNetworkRequest &request)
Posts a request to obtain the contents of the target request and returns a new QNetworkReply object o...
QNetworkReply * sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data=nullptr)
QNetworkReply * deleteResource(const QNetworkRequest &request)
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
void finished()
This signal is emitted when the reply has finished processing.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QRestReply is a convenience wrapper for QNetworkReply.
Definition qrestreply.h:24
QNetworkAccessManager manager
QNetworkRequest request(url)
QJsonDocument myJson
[1]
QNetworkReply * reply
[0]