Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
src_network_access_qnetworkrequestfactory.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
using
namespace
Qt::StringLiterals;
4
5
//! [0]
6
// Instantiate a factory somewhere suitable in the application
7
QNetworkRequestFactory
api
{{
"https://example.com/v1"_L1
}};
8
9
// Set bearer token
10
api.setBearerToken(
"my_token"
);
11
12
// Issue requests (reply handling omitted for brevity)
13
manager.get(api.createRequest(
"models"_L1
));
// https://example.com/v1/models
14
// The conventional leading '/' for the path can be used as well
15
manager.get(api.createRequest(
"/models"_L1
));
// https://example.com/v1/models
16
//! [0]
17
18
19
//! [1]
20
// Here the API version v2 is used as the base path:
21
QNetworkRequestFactory
api
{{
"https://example.com/v2"_L1
}};
22
// ...
23
manager.get(api.createRequest(
"models"_L1
));
// https://example.com/v2/models
24
// Equivalent with a leading '/'
25
manager.get(api.createRequest(
"/models"_L1
));
// https://example.com/v2/models
26
//! [1]
api
QNetworkRequestFactory api
[0]
Definition
src_network_access_qnetworkrequestfactory.cpp:7
qtbase
src
network
doc
snippets
code
src_network_access_qnetworkrequestfactory.cpp
Generated on
for Qt by
1.18.0