2012-07-26 2 views
8
#include<QMetaType> 

    typedef QList<int> IntList; 

    qRegisterMetaType<IntList>("IntList"); 


error C2909: 'qRegisterMetaType': explicit instantiation of function template requires return type 

C2909 내가 정의하면 그때 위에서 언급 한 것처럼 나는이 오류가 왜 나는 아래의 오류qRegisterMetaType 사용은

error C2059: syntax error : 'string' 
warning C4667: 'int qRegisterMetaType(void)' : no function template defined that matches forced instantiation 

을 얻을

template int qRegisterMetaType<IntList>("IntList"); 

를 정의 할 필요가 말한다?

+0

헤더 파일에서 이러한 유형을 선언하고 있습니다. 함수 내에서 같은 것을 선언 할 때 main()이라고 말하십시오. 이 컴파일 오류가 발생하지 않습니다. – Srikan

답변

8

"qRegisterMetaType"은 함수입니다. 코드 블록에 나타나야합니다.

+0

완벽한 ... 일한 :-) – NDestiny

0
int metatype_id = qRegisterMetaType<IntList>("IntList"); 
1

등록하기 전에 Q_DECLARE_METATYPE(IntList)을 추가해야합니다.