Qt的Q_CLASSINFO简要分析
作者:互联网
新建一个继承于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代码:
一对比,一目了然
测试下,如下:
标签:MyInfo,简要,Qt,OBJECT,explicit,QObject,public,CLASSINFO 来源: https://www.cnblogs.com/xingzaicpp/p/16663530.html