variable `xxx' has initializer but incomplete type

错误:variable `xxx' has initializer but incomplete type 
原因:xxx对应的类型没有找到,只把xxx声明了但是没给出定义。编译器无从确认你调用的构造函数是什么,在哪儿
一般是没有包含定义xxx的头文件。

比如:

 1     MyClass theObj;
 2     const QMetaObject* metaObj = theObj.metaObject();
 3     //1.遍历类的属性
 4     int propertyCnt = metaObj->propertyCount();
 5     for ( int i = 0; i < propertyCnt; ++ i )
 6     {
 7         QMetaProperty oneProperty = metaObj->property(i);
 8         std::cout << " name: " << oneProperty.name();
 9         std::cout << " type: " << QVariant::typeToName( oneProperty.type()) << "
";
10     }

不包含头文件的话会报一下错误:

使用#include <QMetaProperty>即可。

原文地址:https://www.cnblogs.com/liushui-sky/p/5729085.html