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
qtresource.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \macro void Q_INIT_RESOURCE(name)
6 \relates <QtResource>
7
8 Initializes the resources specified by the \c .qrc file with the
9 specified base \a name. Normally, when resources are built as part
10 of the application, the resources are loaded automatically at
11 startup. The Q_INIT_RESOURCE() macro is necessary on some platforms
12 for resources stored in a static library.
13
14 For example, if your application's resources are listed in a file
15 called \c myapp.qrc, you can ensure that the resources are
16 initialized at startup by adding this line to your \c main()
17 function:
18
19 \snippet code/src_corelib_io_qdir.cpp 13
20
21 If the file name contains characters that cannot be part of a valid C++ function name
22 (such as '-'), they have to be replaced by the underscore character ('_').
23
24 \note This macro cannot be used in a namespace. It should be called from
25 main(). If that is not possible, the following workaround can be used
26 to init the resource \c myapp from the function \c{MyNamespace::myFunction}:
27
28 \snippet code/src_corelib_io_qdir.cpp 14
29
30 \sa Q_CLEANUP_RESOURCE(), {The Qt Resource System}
31*/
32
33/*!
34 \since 4.1
35 \macro void Q_CLEANUP_RESOURCE(name)
36 \relates <QtResource>
37
38 Unloads the resources specified by the \c .qrc file with the base
39 name \a name.
40
41 Normally, Qt resources are unloaded automatically when the
42 application terminates, but if the resources are located in a
43 plugin that is being unloaded, call Q_CLEANUP_RESOURCE() to force
44 removal of your resources.
45
46 \note This macro cannot be used in a namespace. Please see the
47 Q_INIT_RESOURCE documentation for a workaround.
48
49 Example:
50
51 \snippet code/src_corelib_io_qdir.cpp 15
52
53 \sa Q_INIT_RESOURCE(), {The Qt Resource System}
54*/