首页 > 其他分享 >Qt的Q_CLASSINFO简要分析

Qt的Q_CLASSINFO简要分析

时间:2022-09-06 22:22:07浏览次数:61  
标签:MyInfo 简要 Qt OBJECT explicit QObject public 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
From: https://www.cnblogs.com/xingzaicpp/p/16663530.html

相关文章