How can i store Custom types in QSettings?

qt

Solution

`qRegisterMetaTypeStreamOperators` is a function, not a macro.

You need to call it from a .cpp file, e.g. in your main() method

Problem

From API docs: Custom types registered using qRegisterMetaType() and qRegisterMetaTypeStreamOperators() can be stored using QSettings. How can I do that? I get the error: too few template-parameter-lists at `qRegisterMetaTypeStreamOperators` My code: ``` class LineUser { public: int uId; QString passwd; qint8 statusType; }; Q_DECLARE_METATYPE(LineUser) QDataStream &operator<<(QDataStream &out, const LineUser &myObj) { out<<myObj.uId<<myObj.passwd<<myObj.statusType; return out; } QDataStream &operator>>(QDataStream &in, LineUser &myObj) { in>>myObj.uId>>myObj.passwd>>myObj.statusType; return in; } qRegisterMetaTypeStreamOperators<LineUser>("LineUser"); ```

Original source