summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qobject.cpp33
-rw-r--r--src/corelib/kernel/qtmetamacros.h11
2 files changed, 37 insertions, 7 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index d4b345c2d4..8d131cecc5 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4400,8 +4400,8 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\since 5.5
This macro registers an enum type with the meta-object system.
- It must be placed after the enum declaration in a class that has the Q_OBJECT or the
- Q_GADGET macro. For namespaces use \l Q_ENUM_NS() instead.
+ It must be placed after the enum declaration in a class that has the Q_OBJECT,
+ Q_GADGET or Q_GADGET_EXPORT macro. For namespaces use \l Q_ENUM_NS() instead.
For example:
@@ -4519,7 +4519,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\snippet signalsandslots/signalsandslots.h 3
\note This macro requires the class to be a subclass of QObject. Use
- Q_GADGET instead of Q_OBJECT to enable the meta object system's support
+ Q_GADGET or Q_GADGET_EXPORT instead of Q_OBJECT to enable the meta object system's support
for enums in a class that is not a QObject subclass.
\sa {Meta-Object System}, {Signals and Slots}, {Qt's Property System}
@@ -4540,6 +4540,33 @@ QDebug operator<<(QDebug dbg, const QObject *o)
Q_GADGET makes a class member, \c{staticMetaObject}, available.
\c{staticMetaObject} is of type QMetaObject and provides access to the
enums declared with Q_ENUMS.
+
+ \sa Q_GADGET_EXPORT
+*/
+
+/*!
+ \macro Q_GADGET_EXPORT(EXPORT_MACRO)
+ \relates QObject
+ \since 6.3
+
+ The Q_GADGET_EXPORT macro works exactly like the Q_GADGET macro.
+ However, the \c{staticMetaObject} variable that is made available (see
+ Q_GADGET) is declared with the supplied \a EXPORT_MACRO qualifier. This is
+ useful if the object needs to be exported from a dynamic library, but the
+ enclosing class as a whole should not be (e.g. because it consists of mostly
+ inline functions).
+
+ For example:
+
+ \code
+ class Point {
+ Q_GADGET_EXPORT(EXPORT_MACRO)
+ Q_PROPERTY(int x MEMBER x)
+ Q_PROPERTY(int y MEMBER y)
+ ~~~
+ \endcode
+
+ \sa Q_GADGET, {Creating Shared Libraries}
*/
/*!
diff --git a/src/corelib/kernel/qtmetamacros.h b/src/corelib/kernel/qtmetamacros.h
index 96b1ada57e..fb4dfc5b0d 100644
--- a/src/corelib/kernel/qtmetamacros.h
+++ b/src/corelib/kernel/qtmetamacros.h
@@ -171,10 +171,10 @@ private: \
#define Q_OBJECT_FAKE Q_OBJECT QT_ANNOTATE_CLASS(qt_fake, "")
#ifndef QT_NO_META_MACROS
-/* qmake ignore Q_GADGET */
-#define Q_GADGET \
+/* qmake ignore Q_GADGET_EXPORT */
+#define Q_GADGET_EXPORT(...) \
public: \
- static const QMetaObject staticMetaObject; \
+ static __VA_ARGS__ const QMetaObject staticMetaObject; \
void qt_check_for_QGADGET_macro(); \
typedef void QtGadgetHelper; \
private: \
@@ -185,7 +185,10 @@ private: \
QT_ANNOTATE_CLASS(qt_qgadget, "") \
/*end*/
-/* qmake ignore Q_NAMESPACE_EXPORT */
+/* qmake ignore Q_GADGET */
+#define Q_GADGET Q_GADGET_EXPORT()
+
+ /* qmake ignore Q_NAMESPACE_EXPORT */
#define Q_NAMESPACE_EXPORT(...) \
extern __VA_ARGS__ const QMetaObject staticMetaObject; \
QT_ANNOTATE_CLASS(qt_qnamespace, "") \