diff options
author | Alejandro Exojo <suy@badopi.org> | 2015-07-05 11:26:12 +0200 |
---|---|---|
committer | Alejandro Exojo Piqueras <suy@badopi.org> | 2015-07-06 17:23:20 +0000 |
commit | 219d99fb25fbe8d18d0bdb15c2465863a1915638 (patch) | |
tree | 74efc04630cd2c64ab62ff0b137448373a81922b /src | |
parent | 0784a2c4aefb01668a4957f26134ed0230773d7b (diff) |
doc: Fix and improve QMetaMethod::tag
Make the example and the explanations a bit more detailed about the
purpose of the feature, and fix the example, as it was not calling
metaObject() on the example object.
Change-Id: Ibf3331ed85601274f43794e3a4143e0d6b86a479
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index e89b914227..bae8c1268b 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1880,13 +1880,14 @@ const char *QMetaMethod::typeName() const way in the function declaration: \code + // In the class MainWindow declaration #ifndef Q_MOC_RUN - // define the tag text - # define THISISTESTTAG + // define the tag text as empty, so the compiler doesn't see it + # define MY_CUSTOM_TAG #endif ... private slots: - THISISTESTTAG void testFunc(); + MY_CUSTOM_TAG void testFunc(); \endcode and the information can be accessed by using: @@ -1896,12 +1897,14 @@ const char *QMetaMethod::typeName() const win.show(); int functionIndex = win.metaObject()->indexOfSlot("testFunc()"); - QMetaMethod mm = metaObject()->method(functionIndex); - qDebug() << mm.tag(); // prints THISISTESTTAG + QMetaMethod mm = win.metaObject()->method(functionIndex); + qDebug() << mm.tag(); // prints MY_CUSTOM_TAG \endcode For the moment, \c moc will extract and record all tags, but it will not - handle any of them specially. + handle any of them specially. You can use the tags to annotate your methods + differently, and treat them according to the specific needs of your + application. \note Since Qt 5.0, \c moc expands preprocessor macros, so it is necessary to surround the definition with \c #ifndef \c Q_MOC_RUN, as shown in the |