[Interest] Is QMetaMethod::tag() functional?

Thiago Macieira thiago.macieira at intel.com
Tue Mar 5 22:43:21 CET 2013


On terça-feira, 5 de março de 2013 21.14.32, Immanuel Weber wrote:
> Mhh, then I must be doing something wrong, here is my code example:

> #ifndef TAGCLASS_H
> #define TAGCLASS_H
> 
> #include <QObject>
> #define MYTAG // bla bla

This is the issue. In Qt 5, moc expands macros, so it must not see the 
expansion.

Take qdbusmacros.h:

#ifndef Q_MOC_RUN
# define Q_NOREPLY
#endif


> That should, as far as I understand, print the name and the tag of each
> invokable function of TagClass, but on my system (Win7x64 + Qt5.0.1x86) no
> tag is being printed for testFunc() :(

Yup. Take this source code, for example (it doesn't #include anything, it's 
just for testing):

#define Q_NOREPLY
class MyObject: public QObject {
Q_OBJECT
public slots:
    Q_NOREPLY void foo();
};

When processed with qdbuscpp2xml from Qt 4.8, it prints:
    <method name="foo">
      <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
    </method>

When processed with Qt 5, it prints:
    <method name="foo">
    </method>

It goes back to the original behaviour if I remove the #define line.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130305/c5542ae5/attachment.sig>


More information about the Interest mailing list