Does QML support access specifiers like Private for properties?

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.

Answers


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.


Need Your Help

operator suffix for std::string in c++14

c++ c++11 c++14

I install Clang 3.4, and test suffix operator for string literal ""s.

ReactJS how to scroll to an element

javascript reactjs ecmascript-6

I have a chat widget that pulls up an array of messages everytime I scroll up. The problem I am facing now is, the slider stays fixed at the top when messages load, I want it to focus on the last i...