summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp24
-rw-r--r--src/corelib/kernel/qobject.cpp9
2 files changed, 20 insertions, 13 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
index 43bcc22720..fddda64b19 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp
@@ -403,20 +403,28 @@ public:
//! [39]
-class QLibrary : public QObject
+class QItemSelectionModel : public QObject
{
Q_OBJECT
public:
...
-
- enum LoadHint {
- ResolveAllSymbolsHint = 0x01,
- ExportExternalSymbolsHint = 0x02,
- LoadArchiveMemberHint = 0x04
+ enum SelectionFlag {
+ NoUpdate = 0x0000,
+ Clear = 0x0001,
+ Select = 0x0002,
+ Deselect = 0x0004,
+ Toggle = 0x0008,
+ Current = 0x0010,
+ Rows = 0x0020,
+ Columns = 0x0040,
+ SelectCurrent = Select | Current,
+ ToggleCurrent = Toggle | Current,
+ ClearAndSelect = Clear | Select
};
- Q_DECLARE_FLAGS(LoadHints, LoadHint)
- Q_FLAG(LoadHint)
+
+ Q_DECLARE_FLAGS(SelectionFlags, SelectionFlag)
+ Q_FLAG(SelectionFlags)
...
}
//! [39]
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 8be10ed601..23e4e1163c 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4493,16 +4493,15 @@ QDebug operator<<(QDebug dbg, const QObject *o)
that values of a given enum can be used as flags and combined using the
bitwise OR operator. For namespaces use \l Q_FLAG_NS() instead.
- The macro must be placed after the enum declaration.
+ The macro must be placed after the enum declaration. The declaration of
+ the flags type is done using the \l Q_DECLARE_FLAGS() macro.
- For example, in QLibrary, the \l{QLibrary::LoadHints}{LoadHints} flag is
+ For example, in QItemSelectionModel, the
+ \l{QItemSelectionModel::SelectionFlags}{SelectionFlags} flag is
declared in the following way:
\snippet code/src_corelib_kernel_qobject.cpp 39
- The declaration of the flags themselves is performed in the public section
- of the QLibrary class itself, using the \l Q_DECLARE_FLAGS() macro.
-
\note The Q_FLAG macro takes care of registering individual flag values
with the meta-object system, so it is unnecessary to use Q_ENUM()
in addition to this macro.