Frameworks Sessions
New QML Elements
It’s useful to have access to global data structures in applications to capture state of the business logic in a form of singleton. In QML it is not different but so far (in 5.1 and before) there were no official means to do that without asking C++ or JavaScript for help. This is going to change with a new notation of a QML singleton based on a new pragma keyword:// OtherType.qml
pragma singleton
import QtQml 2.0
QtObject {
property int foo: 3
}
// main.qml
import QtQuick 2.2
import "."
Item {
width: 20 + OtherType.foo
}
pragma singleton
import QtQml 2.0
QtObject {
property int foo: 3
}
// main.qml
import QtQuick 2.2
import "."
Item {
width: 20 + OtherType.foo
}