查看完整版本: [-- constructorCount()为什么没有呢 --]

QTCN开发网 -> Qt基础编程 -> constructorCount()为什么没有呢 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

djm488 2021-01-16 09:22

constructorCount()为什么没有呢

MainWindow::MainWindow(QWidget *parent)    : QMainWindow(parent)    , ui(new Ui::MainWindow){  
ui->setupUi(this);    
qDebug()<<this->metaObject()->constructorCount();      //l输出0
qDebug()<<MainWindow::staticMetaObject.constructorCount();   //l输出0
//getQMetaObject();
}
为什么构造方法是0呢


gnibuoz 2021-01-17 16:00
看网上说法应该是这个【构造函数个数】仅统计 被标记为【Q_INVOKABLE or Q_SCRIPTABLE】的构造函数,原文如下:

Not a bug. As you've discovered, constructors are only extracted if they are marked Q_INVOKABLE or Q_SCRIPTABLE. The same applies to rergular methods, except that slots and signals are automatically invocable.
链接是这个: https://bugreports.qt.io/browse/QTBUG-76348



djm488 2021-01-18 08:23
gnibuoz:看网上说法应该是这个【构造函数个数】仅统计 被标记为【Q_INVOKABLE or Q_SCRIPTABLE】的构造函数,原文如下:
Not a bug. As you've discovered, constructors are only extracted if they are marked Q_INVOKABLE or Q_SCRIPTABLE. The same applies to rergular methods, .. (2021-01-17 16:00) 

了解了,谢谢


查看完整版本: [-- constructorCount()为什么没有呢 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled