新建一个继承于QObject的空白类,如下:
class MyInfo : public QObject
{
Q_OBJECT
public:
explicit MyInfo(QObject *parent = nullptr);
signals:
public slots:
};
然后加上Q_CLASSINFO,如下:
class MyInfo : public QObject
{
Q_OBJECT
Q_CLASSINFO("Version", "1.0.0")
Q_CLASSINFO("Author", "xingzaicpp")
public:
explicit MyInfo(QObject *parent = nullptr);
signals:
public slots:
};
对比生成的moc代码:
一对比,一目了然
测试下,如下: