typedef struct s_mystruct
{
int car;
double wife;
bool isActive;
// QHash <int,QString> map;
// QRect rect;
}
t_mystruct;
Q_DECLARE_METATYPE(t_mystruct);
inline QDataStream& operator<<(QDataStream& out, const t_mystruct& st)
{
out << st.car;
out << st.wife;
out << st.isActive;
return out;
}
inline QDataStream& operator>>(QDataStream& in, t_mystruct& st)
{
in >> st.car;
in >> st.wife;
in >> st.isActive;
return in;
}
int main (int argc,char *argv[])
{
t_mystruct st;
st.car = 2;
st.wife = 3.5;
st.isActive = false;
//st.rect = QRect(1,2,3,4);
settings.setValue("NoOfCars",st.car);
settings.setValue("wife",st.wife);
settings.setValue("isActive",st.isActive);
qRegisterMetaTypeStreamOperators<t_mystruct>("MyStruct");
settings.setValue("struct",st);//<-- i got no matching call for setValue (const char[7],t_mystruct&)
.... some showing of some widget happen here just for test
typedef struct s_mystruct
{
int car;
double wife;
bool isActive;
// QHash <int,QString> map;
// QRect rect;
}
t_mystruct;
Q_DECLARE_METATYPE(t_mystruct);
inline QDataStream& operator<<(QDataStream& out, const t_mystruct& st)
{
out << st.car;
out << st.wife;
out << st.isActive;
return out;
}
inline QDataStream& operator>>(QDataStream& in, t_mystruct& st)
{
in >> st.car;
in >> st.wife;
in >> st.isActive;
return in;
}
int main (int argc,char *argv[])
{
QApplication app(argc,argv);
t_mystruct st;
st.car = 2;
st.wife = 3.5;
st.isActive = false;
//st.rect = QRect(1,2,3,4);
QSettings settings("someone.xfg",QSettings::IniFormat);
settings.setValue("NoOfCars",st.car);
settings.setValue("wife",st.wife);
settings.setValue("isActive",st.isActive);
qRegisterMetaTypeStreamOperators<t_mystruct>("MyStruct");
settings.setValue("struct",st);//<-- i got no matching call for setValue (const char[7],t_mystruct&)
.... some showing of some widget happen here just for test
To copy to clipboard, switch view to plain text mode
Bookmarks