2008-12-09 29 views

回答

6

你需要在.h文件某處聲明如下:

Q_DECLARE_METATYPE(MyStruct) 

,然後你可以使用:

MyStruct s; 
QVariant var; 
var.setValue(s); // copy s into the variant 

// retrieve the value 
MyStruct s2 = var.value<MyStruct>(); 

see the docs here

相關問題