Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只想知道我们是否有任何概念访问说明符,例如 QML 中的私有属性,就像我们在 C++ 中一样。
如果不是,是否想知道我的 QML 组件中有大约 10 个属性,但我必须将访问权限限制为仅 2 个属性。我们如何才能实现这种情况。
QML 本身没有这样的内置功能,但这是 Qt Quick Components 方法:
Item { property int sum: internal.a + internal.b QtObject { id: internal property int a: 1 property int b: 2 } }
“内部”对象的属性在 Item 之外是不可见的,但可以在其内部自由使用。