Is there a way to use different QtQuick widgets in a ListView based on a QVariant's data type?
If my QVariant is a boolean type, the widget would be a Checkbox. If it is an integer, the widget would be a SpinBox. If it is a QString, the widget would be a TextBox.
...etc...
I would like to load/save my application settings with QSettings.
For example:
QSettings settings("userSettings.ini", QSettings::IniFormat);
setAutoUpdate(settings.value("AutoUpdate").toBool());
setAutoUpdateFrequency(settings.value("AutoUpdateFrequency").toInt());
setLastFilePath(settings.value("LastFilePath").toString());
As can be inferred by the conversions, my autoUpdate
type is a boolean, my autoUpdateFrequency
is an integer, and my lastFilePath
is a QString. I was hoping to populate a list within a Settings/Preferences dialog box without having to hard-code and manually position each of the values on the form.
One suggestion by a coworker was that Javascript could determine the QVariant type at creation time and create the new widget, hook up all the necessary properties to the model, and so forth. I'm not sure if that would work, or whether that's the right approach for this situation.