qt - Change a QML widget at runtime -
Is there any way to use different QtQuick widgets in a ListView based on the data type of QVariant?
If my QVariant is a Boolean type, then the widget will be a checkbox if it is an integer, then the widget will be a spin box. If it is astrostring, then the widget will be a text box.
... etc ...
I would like to load / save my application settings with queuing.
For example:
QSettings Settings ("userSettings.ini", QSettings :: IniFormat); SetAutoUpdate (settings.value ("auto update") toBool ().); SetAutoUpdateFrequency (settings.value ("AutoUpdateFrequency") toInt ().); SetLastFilePath (settings.value ("LastFilePath") toString ().);
can be guessed as conversions, my auto update
type is a boolean, my auto update incomplete
is an integer And my last file path
is a cast string I was hoping to populate a list within the Settings / Preferences dialog box without hard work and hope to present each value manually on the form was doing.
A colleague had made a suggestion to type the JavaScript QVariant at the time of creation and create a new widget, hook the model to all the necessary properties, and further. I'm not sure whether this will work, or is it the right approach to the situation or not?
item {width: parent; method; Height: Parents.High loader {id: myLoader source: parent.width & lt; 200? "ConditionMet.qml": "ConditionNotMet.qml" width: 200 height: 100}}
This is a sample code that you can use to load different modules Can be used. You can use the same to fit your case.
Basically use loader with conditional source.
Comments
Post a Comment