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代码:
一对比,一目了然
测试下,如下:
本文来自博客园,作者:xingzaicpp,转载请注明原文链接:https://www.cnblogs.com/xingzaicpp/p/16663530.html