From d023d149d934897515a532a483def76801b93585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20De=20Canni=C3=A8re?= Date: Fri, 10 Feb 2023 16:05:54 +0100 Subject: NetworkAccessManagerFactory: Complete documentation page with snippets Pick-to: 6.5 6.5.0 Fixes: QTBUG-110657 Change-Id: I063eb4ac25cbe226b5a996014042515d6ada5468 Reviewed-by: Fabian Kosmale --- .../src_network_access_qnetworkaccessmanager.cpp | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/qml/doc/snippets/code/src_network_access_qnetworkaccessmanager.cpp (limited to 'src/qml/doc/snippets/code') diff --git a/src/qml/doc/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/src/qml/doc/snippets/code/src_network_access_qnetworkaccessmanager.cpp new file mode 100644 index 0000000000..b200261035 --- /dev/null +++ b/src/qml/doc/snippets/code/src_network_access_qnetworkaccessmanager.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +//! [0] +class CachingNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory +{ +public: + + inline QNetworkAccessManager *create(QObject *parent) override + { + QNetworkAccessManager *networkAccessManager = new QNetworkAccessManager(parent); + QNetworkDiskCache *diskCache = new QNetworkDiskCache(parent); + diskCache->setCacheDirectory("requestCache"); + networkAccessManager->setCache(diskCache); + + return networkAccessManager; + } +}; +//! [0] + +//! [1] +CachingNetworkAccessManagerFactory networkManagerFactory; +engine->setNetworkAccessManagerFactory(&networkManagerFactory); +//! [1] -- cgit v1.2.1