2
恢復的QList
settings.setValue("profilesEnabled", QVariant::fromValue< QList<bool> >(profilesEnabled));
還原:
profilesEnabled = settings.value("profilesEnabled").toList()); //error
但toList()還給的QVariant的QList,使用和profilesEnabled是布爾的的QList。
有沒有優雅的方法來轉換它? (我可以通過的QVariant的QList作遍歷,並通過一個轉換一個)
更新:
QVariant var = QVariant::fromValue< QList<bool> >(profilesEnabled);
settings.setValue("profilesEnabled", var);
第二行崩潰運行時間:
QVariant::save: unable to save type 'QList<bool>' (type id: 1031).
ASSERT failure in QVariant::save: "Invalid type to save", file kernel\qvariant.cpp, line 1966
什麼是'settings'的格式?如果您使用'QSettings :: IniFormat',則無法將其保存到文件中。 –