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

Immanuel Weber immanuel.weber at gmail.com
Tue Mar 5 22:14:32 CET 2013


Thiago Macieira <thiago.macieira <at> intel.com> writes:

> 
> On terça-feira, 5 de março de 2013 10.51.31, Immanuel Weber wrote:
> > Hi all,
> > 
> > I allready asked that question on the qt-forums, but did not get any
> > response, so maybe here somebody can help me.
> > I tried to use the QMetaMethod::tag() feature as described in the
> > documentation, however it does not work.
> > Actually there is a note in the documentation (
> > http://qt-project.org/doc/qt-5.0/qtcore/qmetamethod.html#tag) that states:
> > "For the moment, moc doesn't support any special tags." Does special tag
> > mean, any user specified tag and hence the feature is non-functional?
> 
> No, it works just fine.
> 
> QtDBus has been using and requiring that feature since Qt 4.2.
> 

Mhh, then I must be doing something wrong, here is my code example:

main.cpp:
#include <QCoreApplication>
#include <QMetaMethod>
#include <QDebug>
#include "tagclass.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    auto obj = new TagClass();
    for (int i = 0; i < obj->metaObject()->methodCount(); i++) {
        qDebug() << "name: " << obj->metaObject()->method(i).name() << ", tag: " 
<< obj->metaObject()->method(i).tag();
    }
    return a.exec();
}

tagclass.h:
#ifndef TAGCLASS_H
#define TAGCLASS_H

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

class TagClass: public QObject
{
    Q_OBJECT
public:
    explicit TagClass(QObject * parent = 0) : QObject(parent) {}

public slots:
    MYTAG void testFunc() {}
};

#endif // TAGCLASS_H

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() :(





More information about the Interest mailing list