Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt qRegisterMetaType用法_Qt - Fatal编程技术网

Qt qRegisterMetaType用法

Qt qRegisterMetaType用法,qt,Qt,为什么会出现此错误?int-metatype\u id=qRegisterMetaType(“IntList”); error C2059: syntax error : 'string' warning C4667: 'int qRegisterMetaType(void)' : no function template defined that matches forced instantiation 您需要添加Q\u DECLARE\u元类型(IntList),然后才能注册它。“qR

为什么会出现此错误?

int-metatype\u id=qRegisterMetaType(“IntList”);
 error C2059: syntax error : 'string'
 warning C4667: 'int qRegisterMetaType(void)' : no function template defined that matches forced instantiation

您需要添加
Q\u DECLARE\u元类型(IntList)
,然后才能注册它。

“qRegisterMetaType”是一个函数。它必须出现在代码块中。

我正在头文件中声明这些类型。当我在函数中声明相同的内容时,比如main()。我没有得到这个编译错误。
 template int qRegisterMetaType<IntList>("IntList");
 error C2059: syntax error : 'string'
 warning C4667: 'int qRegisterMetaType(void)' : no function template defined that matches forced instantiation
int metatype_id = qRegisterMetaType<IntList>("IntList");