gpt4 book ai didi

c++ - 属性QtObject marginHints:QtObject {…}

转载 作者:行者123 更新时间:2023-12-02 10:38:53 25 4
gpt4 key购买 nike

查看KDE等离体的来源,一些小部件声明了marginHints属性,例如this:

    property QtObject marginHints: QtObject {
property int left: Math.round(units.smallSpacing / 2)
property int top: Math.round(units.smallSpacing / 2)
property int right: Math.round(units.smallSpacing / 2)
property int bottom: Math.round(units.smallSpacing / 2)
}

尽管没有从任何地方明确引用,但删除它们实际上会破坏布局。

甚至在其他地方也有记载吗?如何运作?这是某种QML魔术吗?

最佳答案

看起来,QML具有比我想象的复杂得多的范围解析。不过,阅读文档(又称RTFM)会有所帮助。

https://doc.qt.io/qt-5/qtqml-documents-scope.html

根据该文章:

Component Scope

Each QML component in a QML document defines a logical scope. Each document has at least one root component, but can also have other inline sub-components. The component scope is the union of the object ids within the component and the component's root object's properties.

[...]

Component Instance Hierarchy

In QML, component instances connect their component scopes together to form a scope hierarchy. Component instances can directly access the component scopes of their ancestors.



将范围合并在一起,该项目的任何子组件的任何内部组件都可能使用过它。

关于c++ - 属性QtObject marginHints:QtObject {…},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55128811/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com