Reputation: 2733
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");
Upvotes: 3
Views: 2019
Reputation: 12600
qRegisterMetaTypeStreamOperators
is a function, not a macro.
You need to call it from a .cpp file, e.g. in your main() method
Upvotes: 4