コンポーネントには子要素が1つだけ存在しなければなりません
qmllintでは、この警告カテゴリは「[component-children-count] 」と表記されます。
コンポーネントには子要素がちょうど1つしか存在してはなりません
何が起きたのか?
コンポーネントの子要素の数が不正です。子要素は正確に1つでなければなりません。
なぜ問題なのでしょうか?
ファイルのルートコンポーネントがインスタンス化できず、実行時にエラーが発生します。
例
Component {
Rectangle {
width: 50
height: 50
color: "red"
}
Rectangle {
width: 50
height: 50
color: "blue"
}
}この警告を解消するには、コンポーネントの子要素が正確に1つであることを確認してください。空の場合は、子要素を追加してください。複数ある場合は、余分な子要素を削除するか、子要素をコンポーネントの単一のトップレベルの子要素にまとめ直してください。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.