variable `xxx' has initializer but incomplete type
2016-08-02 14:15
1486 查看
错误:variable `xxx' has initializer but incomplete type
原因:xxx对应的类型没有找到,只把xxx声明了但是没给出定义。编译器无从确认你调用的构造函数是什么,在哪儿
一般是没有包含定义xxx的头文件。
比如:
不包含头文件的话会报一下错误:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/22/123a62c558c610cede769428cb184246.png)
使用#include <QMetaProperty>即可。
原因:xxx对应的类型没有找到,只把xxx声明了但是没给出定义。编译器无从确认你调用的构造函数是什么,在哪儿
一般是没有包含定义xxx的头文件。
比如:
MyClass theObj; const QMetaObject* metaObj = theObj.metaObject(); //1.遍历类的属性 int propertyCnt = metaObj->propertyCount(); for ( int i = 0; i < propertyCnt; ++ i ) { QMetaProperty oneProperty = metaObj->property(i); std::cout << " name: " << oneProperty.name(); std::cout << " type: " << QVariant::typeToName( oneProperty.type()) << "\n"; }
不包含头文件的话会报一下错误:
![](https://oscdn.geek-share.com/Uploads/Images/Content/202007/22/123a62c558c610cede769428cb184246.png)
使用#include <QMetaProperty>即可。
相关文章推荐
- variable 'std:ofstream' has initializer but incomplete type
- variable `xxx' has initializer but incomplete type
- error: variable ‘QApplication a’ has initializer but incomplete type
- Qt报错: has initializer but incomplete type , 解决办法以及前向声明的错误使用
- 关于错误: error: variable ‘QApplication app’ has initializer but incomplete type
- Error: variable 'QApplication app' has initializer but incomplete type
- variable `xxx' has initializer but incomplete type
- variable 'std:ofstream' has initializer but incomplete type 错误
- paip.variable xxx has initializer but incomplete type 解决方案
- variable 'std:ofstream' has initializer but incomplete type
- qt error: variable `QPainter painter' has initializer but incomplete type
- variable "xxx" has initializer but incomplete type
- variable `xxx' has initializer but incomplete type
- 两个C++编译异常及解决方法-does not name a type和field `XX' has incomplete type
- array element has incomplete type
- jni编译时出现:warning: format '%d' expects argument of type 'int', but argument 4 has
- 编译busybox的时候出现error: field 'in' has incomplete type
- My first CXX problem:"aggregate has incomplete type and cannot be defined"
- Error tips:array type has incomplete element type
- 解决 has incomplete type