尝试序列化自定义类时出错。我正在使用 QDataStream 运算符 << 和 >> 来写入和读取我的对象。
当我尝试写入或读取 boolean 时发生错误:
error: ambiguous overload for 'operator<<' (operand types are 'QDataStream' and 'const bool')
QDataStream & operator << (QDataStream & out, const sys_settings & Value)
{
out << Value.myBool
<< Value.someString;
return out;
}
QDataStream & operator >> (QDataStream & in, sys_settings & Value)
{
in >> Value.myBool;
in >> Value.someString
return in;
}