我正在尝试使用QSettings在我的QT App中保存一些设置。对于我已经定义了一个类型:如何将QMap存储到QSetting变量中
typedef QMap
<
QString,
QMap<QString, QVariant>
>
QSession;
之后,我有registred它
Q_DECLARE_METATYPE(QSession);
创造一些条目并阅读它们在运行后,使没有问题,但我得到了如下因素错误关闭应用
QVariant::save: unable to save type 'QSession' (type id: 1067).
我节省,功能看起来像
void saveSession()
{
QSession session;
for(auto it = pool.begin(); it != pool.end(); ++it)
{
QString hash(toQString((*it).getHash()));
session[hash]["name"] = toQVariant(toQString((*it).getName()));
session[hash]["size"] = toQVariant((*it).getSize());
session[hash]["timeout"] = toQVariant((*it).getTimeout());
}
this->settings.setValue("session", QVariant::fromValue(session));
}
问题在哪里?谢谢!