I want to declare a global property in a config file and use it in other files. for example declare mainbg
in:
Style.qml:
You can create a js file and import it to all of the files that have to use this property.
js file:
//Note: you only need '.pragma library' if you are planning to
//change this variable from multiple qml files
.pragma library
var globalVariable = 20;
qml file:
import "test.js" as Global
Rectangle {
id: main
width: 300; height: 400
Component.onCompleted: {
console.log( Global.globalVariable)
//you can also change it
Global.globalVariable = 5
}
}