为什么有些 QtQuick 控件有隐藏变量?

Why some QtQuick Controls have the hidden variable?

这个问题实际上来自QtQuick 项的某些属性被隐藏,例如 TreeView 中的 __listView。 我知道有一些复杂的 UI 组件基于其他一些基本组件。

Qt 提供了使用它的可访问性但没有在文档中提及它,这样的隐藏属性确实按预期工作得很好。那么为什么 Qt 隐藏属性呢?我要用吗?

这是Qt4中QML开头创建的约定,我们可以在这个link中找到,Qt5中似乎没有记录:

Private Properties

QML and JavaScript do not enforce private properties like C++. There is a need to hide these private properties, for example, when the properties are part of the implementation. As a convention, private properties begin with two underscore characters. For example, __area, is a property that is accessible but is not meant for public use. Note that QML and JavaScript will grant the user access to these properties.

 Item {
     id: component
     width: 40; height: 50
     property real __area: width * height * 0.5    //not meant for outside use
 }