summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2024-01-04 12:05:31 +0200
committerMarc Mutz <marc.mutz@qt.io>2024-01-14 12:24:31 +0000
commiteb2db79064bd6e74d0b3485a650e4025d0a39c96 (patch)
tree192a4c44d3da64f75b1f93ebd24c8180b54dfa96 /src/corelib/kernel/qobject.cpp
parent8bfebaa22f66d2cc32d6147611bcbaea3a85188c (diff)
QObject: clarify docs wrt. member access following Q_OBJECT and co
The macros expand to declarations that end in a private: section, which means everything following them is private. As Fabian said in the bug report, this is obvious when Q_OBJECT/GADGET ...etc are used in a class, but might be a bit surprising when used in a `struct`. Fixes: QTBUG-120297 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: Iacdfc4eb3bab3554cc1142f682b11b32c3868b8f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8d4e47afb5..62cf083d19 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4710,6 +4710,13 @@ QDebug operator<<(QDebug dbg, const QObject *o)
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.
+//! [qobject-macros-private-access-specifier]
+ \note This macro expansion ends with a \c private: access specifier, which makes member
+ declarations immediately after the macro private, too. If you want add public (or protected)
+ members immediately after the macro, you need to use a \c public: (or \c protected:)
+ access specifier.
+//! [qobject-macros-private-access-specifier]
+
\sa {Meta-Object System}, {Signals and Slots}, {Qt's Property System}
*/
@@ -4729,6 +4736,8 @@ QDebug operator<<(QDebug dbg, const QObject *o)
\c{staticMetaObject} is of type QMetaObject and provides access to the
enums declared with Q_ENUM.
+ \include qobject.cpp qobject-macros-private-access-specifier
+
\sa Q_GADGET_EXPORT
*/
@@ -4754,6 +4763,8 @@ QDebug operator<<(QDebug dbg, const QObject *o)
~~~
\endcode
+ \include qobject.cpp qobject-macros-private-access-specifier
+
\sa Q_GADGET, {Creating Shared Libraries}
*/