Does QML support access specifiers like Private fo

2019-03-11 01:26发布

I just want to know do we have any concept access specifiers like private property in QML as we have in C++.

If not if would like to know in case i have about 10 properties in my QML component but i have to limit the access to only 2 properties. how can we achieve this scenario.

标签: qt qml qt-quick
1条回答
我想做一个坏孩纸
2楼-- · 2019-03-11 02:00

There is no such builtin feature in QML itself, but here is Qt Quick Components approach:

Item {
  property int sum: internal.a + internal.b
  QtObject {
    id: internal
    property int a: 1
    property int b: 2
  }
}

Properties of 'internal' object are invisible outside of Item, but may be freely used inside of it.

查看更多
登录 后发表回答