Qt: Don't store floats in settings as QVariant data

This commit is contained in:
Connor McLaughlin 2020-02-28 17:00:07 +10:00
parent da0059fb21
commit ccbe6f0c42
2 changed files with 3 additions and 3 deletions

View file

@ -59,7 +59,7 @@ void QtSettingsInterface::SetIntValue(const char* section, const char* key, int
void QtSettingsInterface::SetFloatValue(const char* section, const char* key, float value)
{
m_settings.setValue(GetFullKey(section, key), QVariant(value));
m_settings.setValue(GetFullKey(section, key), QString::number(value));
}
void QtSettingsInterface::SetBoolValue(const char* section, const char* key, bool value)
@ -76,7 +76,7 @@ std::vector<std::string> QtSettingsInterface::GetStringList(const char* section,
{
QVariant value = m_settings.value(GetFullKey(section, key));
if (value.type() == QVariant::String)
return { value.toString().toStdString() };
return {value.toString().toStdString()};
else if (value.type() != QVariant::StringList)
return {};

View file

@ -172,7 +172,7 @@ void BindWidgetToNormalizedSetting(QtHostInterface* hi, WidgetType* widget, cons
Accessor::connectValueChanged(widget, [hi, widget, setting_name, range]() {
const float new_value = (static_cast<float>(Accessor::getIntValue(widget)) / range);
hi->putSettingValue(setting_name, new_value);
hi->putSettingValue(setting_name, QString::number(new_value));
hi->applySettings();
});
}