コントロールのウィンドウQMLの問題は、IDレイアウト配置を使用することはできません

クリエイティブコモンズライセンス 著作権:帰属、紙ベースを作成するために他人を許可し、(同じライセンスで元のライセンス契約に基づいて用紙配布する必要がありますクリエイティブコモンズ

ウィンドウはQML問題がIDレイアウト配置を使用することができない解決を制御します。

問題を再現するために、

  • 下部に予想される動作が、同じレイアウト(トップデフォルトのレイアウト)に従い、長方形ではなくを実行した後。
Window {
    id: root
    visible: true
    width: 640
    height: 480

    Rectangle {
    	id: rect
        width: 100; height: 100
        anchors.bottom: root.bottom
        color: "red"
    }
}

分析

  • それがのレイアウト見つけることができないので、まず、手がかりの公式Qtのドキュメントを見て確認しanchors、文書のレイアウトを、グローバル検索によって文書には、以下の情報を見つけました。
Note: You can only anchor an item to siblings or a parent. 
注意:只能将项目锚定到同级或父级。 
  • 窓推測することができるrootのID点がアイテム(又はQQuickItem)に由来するものではありません。
  • idと親プロパティによって印刷ウィンドウがQQuickWindowQmlImplとQQuickRootItemあり、それは確かにされたQQuickWindowQmlImplレイアウトの問題よりも少なく、その結果、QQuickItemには継承されません。
  • 私は間違っている感じが、また次のドキュメントを検索するには、以下の情報を参照してください。
[default] data : list<Object>

The data property allows you to freely mix visual children, resources and other Windows in a Window.
If you assign another Window to the data list, the nested window will become "transient for" the outer Window.
If you assign an Item to the data list, it becomes a child of the Window's contentItem, so that it appears inside the window. The item's parent will be the window's contentItem, which is the root of the Item ownership tree within that Window.
If you assign any other object type, it is added as a resource.
It should not generally be necessary to refer to the data property, as it is the default property for Window and thus all child items are automatically assigned to this property.

data属性允许您在Window中自由混合可视子项,资源和其他Windows。
如果将另一个窗口分配给数据列表,嵌套窗口将变为"瞬态"外部窗口。
如果将一个Item分配给数据列表,它将成为Window的contentItem的子项,以便它出现在窗口内。 项目的父项将是窗口的contentItem,它是该窗口中项目所有权树的根。
如果指定任何其他对象类型,则将其添加为资源。
通常不需要引用data属性,因为它是Window的默认属性,因此所有子项都会自动分配给此属性。
  • おそらく、アイテムウィンドウがルートウィンドウが装着されていることcontentItemに。

ソリューション

  • 使用するparentか、root.contentItemまたはWindow.contentItemその代わりにrootレイアウトとして固定。

おすすめ

転載: blog.csdn.net/nicai_xiaoqinxi/article/details/91549280