Does QML support access specifiers like Private for properties?

前端 未结 1 1661
借酒劲吻你
借酒劲吻你 2021-02-02 13:16

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 propert

相关标签:
1条回答
  • 2021-02-02 13:27

    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.

    0 讨论(0)
提交回复
热议问题