[Solved]Create a read only property in qml
QML and Qt Quick
3
Posts
2
Posters
7.8k
Views
1
Watching
-
wrote on 9 Jul 2013, 02:06 last edited by
//Whatever.qml
@
Rectangle{property string modelType: object.stringModel
//.......
}
@What I want to do is, inside the Whatever.qml the modelType could be read or altered
but for other's components modelType is a read only propertyCurrently I am using function and QObject to hide the property
Do pure qml have other choices for us?Thanks -
wrote on 9 Jul 2013, 06:18 last edited by
In Qt Quick 2, you can actually declare readonly property like this:
@readonly property string modelType: object.stringModel@
In this case you would not be able to modify it after creation. If you need to modify it inside Whatever.qml you could instead create an internal property and declare a public readonly alias to it. -
wrote on 9 Jul 2013, 06:57 last edited by
Thanks for your helps
1/3