Hi. I've been trying to use the Settings type in my application, for which I added the following code to my main.qml file:
import Esri.ArcGISRuntime 100.0
import Esri.ArcGISExtras 1.1 ...
Settings {
id: settings
property string userName: userId
property string loggedUser
}
This code worked for me in the AppStudio. QtCreator seems to recognize the type and I can build the app. However, when debugging the following error is thrown:
qrc:/qml/main.qml:41 The Esri ArcGIS Extras type Settings is not creatable
I did look on the API reference page (Settings QML Type | ArcGIS for Developers ) how to use the Settings in the Qt SDK for ArcGIS, however there were no code examples to be found. Could someone inform me what I'm doing wrong?
Thanks in advance!
Solved! Go to Solution.
Hi Pim,
You are correct that the `Settings` type cannot be created in the declarative way you show in your code.
It also does not support declaring your own properties by name (e.g. 'userName' or 'loggeduser').
Instead, you can access the System objects settings and then call `setValue` or `getValue` as shown in my example code below:
Button { text: "set" onClicked : { System.settings.setValue("test_settings", "hello") } }
Button { text: "set" onClicked : { console.log(System.settings.value("test_settings")) } }
I am not familiar with the Settings type in AppStudio - but if the above code is working, it is possible this is using a different type? For example the Settings type provided by qt-labs has a more declarative interface like the one you show: Settings QML Type | Qt Quick 5.8
I hope that helps,
Luke
Hi Pim,
You are correct that the `Settings` type cannot be created in the declarative way you show in your code.
It also does not support declaring your own properties by name (e.g. 'userName' or 'loggeduser').
Instead, you can access the System objects settings and then call `setValue` or `getValue` as shown in my example code below:
Button { text: "set" onClicked : { System.settings.setValue("test_settings", "hello") } }
Button { text: "set" onClicked : { console.log(System.settings.value("test_settings")) } }
I am not familiar with the Settings type in AppStudio - but if the above code is working, it is possible this is using a different type? For example the Settings type provided by qt-labs has a more declarative interface like the one you show: Settings QML Type | Qt Quick 5.8
I hope that helps,
Luke