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_corelib_io_qfileselector.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QFileSelector>
5#include <QFile>
6#include <QLocale>
7
8void example()
9{
10 {
11 //! [0]
12 QString defaultsBasePath = "data/";
13 QString defaultsPath = defaultsBasePath + "defaults.conf";
14 QString localizedPath = defaultsBasePath
15 + QString("%1/defaults.conf").arg(QLocale().name());
16 if (QFile::exists(localizedPath))
17 defaultsPath = localizedPath;
18 QFile defaults(defaultsPath);
19 //! [0]
20 }
21
22 {
23 //! [1]
24 QString defaultsPath = "data/defaults.conf";
25 #if defined(Q_OS_ANDROID)
26 defaultsPath = "data/android/defaults.conf";
27 #elif defined(Q_OS_IOS)
28 defaultsPath = "data/ios/defaults.conf";
29 #endif
30 QFile defaults(defaultsPath);
31 //! [1]
32
33 //! [2]
34 QFileSelector selector;
35 QFile defaultsFile(selector.select("data/defaults.conf"));
36 //! [2]
37 }
38}
39
40#if 0
41//! [3]
42data/defaults.conf
43data/+android/defaults.conf
44data/+ios/+en_GB/defaults.conf
45//! [3]
46
47//! [4]
48images/background.png
49images/+android/+en_GB/background.png
50//! [4]
51
52//! [5]
53images/background.png
54images/+linux/background.png
55images/+windows/background.png
56images/+admin/background.png
57images/+admin/+linux/background.png
58//! [5]
59#endif
void example()
[5]