QSettings -> The Esri ArcGIS Extras type Settings is not creatable

263
1
Jump to solution
03-15-2017 03:52 AM
PimJanissen
New Contributor II

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!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LukeSmallwood
Esri Contributor

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

View solution in original post

0 Kudos
1 Reply
LukeSmallwood
Esri Contributor

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

View solution in original post

0 Kudos