Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
4//! [0]
5QNetworkReply *reply = manager->get(request);
6QObject::connect(reply, &QNetworkReply::finished, this, [reply]() {
7 // The reply may be wrapped in the finish handler:
8 QRestReply restReply(reply);
9 if (restReply.isSuccess())
10 // ...
11});
12//! [0]
13
14
15//! [1]
16// With lambda
17manager->get(request, this, [this](QRestReply &reply) {
18 if (reply.isSuccess()) {
19 // ...
20 }
21});
22// With member function
23manager->get(request, this, &MyClass::handleFinished);
24//! [1]
25
26
27//! [2]
29// ...
30manager->post(request, myJson, this, [this](QRestReply &reply) {
31 if (!reply.isSuccess()) {
32 // ...
33 }
34 if (std::optional json = reply.readJson()) {
35 // use *json
36 }
37});
38//! [2]
39
40
41//! [3]
42manager->get(request, this, [this](QRestReply &reply) {
43 if (!reply.isSuccess())
44 // handle error
45 if (std::optional json = reply.readJson())
46 // use *json
47});
48//! [3]
49
50
51//! [4]
52manager->get(request, myData, this, [this](QRestReply &reply) {
53 if (reply.isSuccess())
54 // ...
55});
56//! [4]
57
58
59//! [5]
60manager->post(request, myData, this, [this](QRestReply &reply) {
61 if (reply.isSuccess())
62 // ...
63});
64//! [5]
65
66
67//! [6]
68manager->put(request, myData, this, [this](QRestReply &reply) {
69 if (reply.isSuccess())
70 // ...
71});
72//! [6]
73
74
75//! [7]
76manager->head(request, this, [this](QRestReply &reply) {
77 if (reply.isSuccess())
78 // ...
79});
80//! [7]
81
82
83//! [8]
84manager->deleteResource(request, this, [this](QRestReply &reply) {
85 if (reply.isSuccess())
86 // ...
87});
88//! [8]
89
90
91//! [9]
92manager->sendCustomRequest(request, "MYMETHOD", myData, this, [this](QRestReply &reply) {
93 if (reply.isSuccess())
94 // ...
95});
96//! [9]
97
98
99//! [10]
100manager->patch(request, myData, this, [this](QRestReply &reply) {
101 if (reply.isSuccess())
102 // ...
103});
104//! [10]
QNetworkReply * reply
[0]
QJsonDocument myJson
[1]