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
qplugin.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \headerfile <QtPlugin>
6 \inmodule QtCore
7 \title Defining Plugins
8 \keyword qtplugin-defining-plugins
9 \ingroup plugins
10
11 \brief The <QtPlugin> header file defines macros for defining plugins.
12
13 \sa {How to Create Qt Plugins}
14*/
15
16/*!
17 \macro Q_DECLARE_INTERFACE(ClassName, Identifier)
18 \relates <QtPlugin>
19
20 This macro associates the given \a Identifier (a string literal)
21 to the interface class called \a ClassName. The \a Identifier must
22 be unique.
23
24 This macro is normally used right after the class definition for
25 \a ClassName, in a header file.
26
27 If you want to use Q_DECLARE_INTERFACE with interface classes
28 declared in a namespace then you have to make sure the Q_DECLARE_INTERFACE
29 is not inside a namespace though. For example:
30 \snippet code/doc_src_qplugin.cpp 0
31
32 \sa Q_INTERFACES(), {How to Create Qt Plugins}
33*/
34
35/*!
36 \macro Q_PLUGIN_METADATA(...)
37 \relates <QtPlugin>
38 \since 5.0
39
40 This macro is being used to declare meta data that is part of a plugin
41 that instantiates this object.
42
43 The macro needs to declare the IID of the interface implemented through
44 the object, and reference a file containing the meta data for the plugin.
45
46 There should be exactly one occurrence of this macro in the source code
47 for a Qt plugin.
48
49 Example:
50
51 \snippet code/doc_src_qplugin.cpp 1
52
53 Note that the class this macro appears on must be default-constructible.
54
55 FILE is optional and points to a json file.
56
57 The json file must reside in one of the include directories specified
58 by the build-system.
59 moc exits with an error when it could not find the specified file.
60
61 \sa Q_DECLARE_INTERFACE(), {How to Create Qt Plugins}
62*/
63
64/*!
65 \macro Q_IMPORT_PLUGIN(PluginName)
66 \relates <QtPlugin>
67
68 This macro imports the plugin named \a PluginName, which corresponds
69 with the name of the class that declares metadata for the plugin with
70 Q_PLUGIN_METADATA().
71
72 Inserting this macro into your application's source code will allow
73 you to make use of a static plugin.
74
75 Example:
76
77 \snippet code/doc_src_qplugin.cpp 2
78
79 Static plugins must also be included by the linker when your
80 application is built. See \l{Static Plugins} for more information
81 on this.
82
83 \sa {Static Plugins}, {How to Create Qt Plugins}
84
85*/