For me, the documentation generally give little or nothing in the way of example/s.
Perhaps we should have a thread where we can submit new, simple examples that give basics for beginners and for them to be included in the docs we can view within SDK.
For me, ConfigurationGroup is one module that gives absolutely NO VISUAL CLUE how to write/implement code, yet everything we need to know is written on that page, but no example given.
Fortunately, when I used to be able to access talk.maemo.org, I asked about ConfigGroup and was furnished with a really simple example, which is now emblazoned on my brain. I forget the name of the user who gave the code, something like “Velo”.
Regardless, I will plop the code here anyway, I call it Color Recall. A simple example that saves the color chosen by the user. When the app is opened next time, that last color is there in rectangle form.
import QtQuick 2.2
import Sailfish.Silica 1.0
import Nemo.Configuration 1.0
Page {
allowedOrientations: Orientation.All
Rectangle {
id: rect
color: "#00000000"
width: 500
height: width
anchors.centerIn: parent
ConfigurationGroup {
id: settings
path: "/apps/harbour-color-recall"
}
Component.onDestruction: {
settings.setValue("rectColor", rect.color)
console.log(rect.color)
}
Component.onCompleted: {
rect.color = settings.value("rectColor", "#000000");
console.log(rect.color)
}
MouseArea {
anchors.fill: parent
onClicked: {
rect.color = Qt.rgba(Math.random(), 0.4, 0.6, 0.8);
console.log(rect.color)
}
}
}