code_junkie

qt/c++ casting question

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.16 KB | None | 0 0
  1. Q_DECLARE_METATYPE(MyStruct)
  2.  
  3. MyStruct s;
  4. QVariant var;
  5. var.setValue(s); // copy s into the variant
  6.  
  7. // retrieve the value
  8. MyStruct s2 = var.value<MyStruct>();
Add Comment
Please, Sign In to add comment