I tried to register a struct in QVariant see code below, I was trying to test if i could save it in QSetting::setValue(key,QVariant&) and found that it won't work, can someone point out my mistake ? what did i do wrong?

Qt Code:
  1. typedef struct s_mystruct
  2. {
  3. int car;
  4. double wife;
  5. bool isActive;
  6. // QHash <int,QString> map;
  7. // QRect rect;
  8. }
  9. t_mystruct;
  10. Q_DECLARE_METATYPE(t_mystruct); // registering my struct here
  11.  
  12. int main (int argc,char *argv[])
  13. {
  14. QApplication app(argc,argv);
  15. t_mystruct st;
  16. st.car = 2;
  17. st.wife = 3.5;
  18. st.isActive = false;
  19. //st.rect = QRect(1,2,3,4);
  20.  
  21. QSettings settings("someCode.xfg",QSettings::IniFormat);
  22.  
  23. settings.setValue("NoOfCars",st.car);
  24. settings.setValue("wife",st.wife);
  25. settings.setValue("isActive",st.isActive);
  26. s.setValue(st);
  27. settings.setValue("struct",s); // nothing is saved on somCode.xfg but compiled ok
  28. /* note: Process terminated with status 1 (0 minutes, 3 seconds)
  29.   is the result when i try to run my program with
  30.   settings.setValue("struct",s) line on
  31. */
  32.  
  33. QPushButton *mainWin = new QPushButton; //just to have something going
  34. mainWin->show();
  35.  
  36. return app.exec();
  37.  
  38. }
To copy to clipboard, switch view to plain text mode 

baray98