[Interest] how to add comments of member function defined with macro?

Sze Howe Koh szehowe.koh at gmail.com
Tue Feb 26 05:32:06 CET 2013


On 26 February 2013 11:54, tang ke <tangk at lemote.com> wrote:
> Hey everybody!
> How can I use the macro with qdoc?
> Such as:
> I defined a macro with macro-def.h
>
> #define _DECLARE_INT2ENUMSTRING(Enum) \
> QString int2string(int value) { \
> const QMetaObject* meta = this->metaObject(); \
> for (int j = 0; j < meta->enumeratorCount(); ++j) { \
> QMetaEnum m = meta->enumerator(j); \
> if(QString(m.name()) == QString(Enum)) { \
> return QString(m.valueToKey(value)); \
> } \
> } \
> return QString(""); \
> }
>
> with class header file, I use this macro to define a member function.
>
> _DECLARE_INT2ENUMSTRING("BUTTON")
>
> so How can I add the comments of this member function?

You can use the \fn command:
http://doc-snapshot.qt-project.org/qt5-stable/qdoc/13-qdoc-commands-topics.html#fn-command

Note that the comment must be in a .cpp file, not a .h file.

Why don't you create a normal function, instead of using a macro?


Regards,
Sze-Howe



More information about the Interest mailing list