#include<QMetaType>
typedef QList<int> IntList;
qRegisterMetaType<IntList>("IntList");
error C2909: 'qRegisterMetaType': explicit instantiation of function template requires return type
C2909说我需要定义
template int qRegisterMetaType<IntList>("IntList");
如果我像上面提到的那样定义,那么我得到以下错误
error C2059: syntax error : 'string'
warning C4667: 'int qRegisterMetaType(void)' : no function template defined that matches forced instantiation
为什么我会收到此错误?
答案 0 :(得分:11)
&#34; qRegisterMetaType&#34;是一个功能。它必须出现在代码块中。
答案 1 :(得分:2)
您需要先添加Q_DECLARE_METATYPE(IntList)
才能注册。
答案 2 :(得分:1)
int metatype_id = qRegisterMetaType<IntList>("IntList");