Components must have exactly one child

This warning category is spelled [component-children-count] by qmllint.

Components must have exactly one child

What happened?

A Component has the wrong number of children. It must have exactly one.

Why is that bad?

The root component of the file won't be instantiable and will cause an error at runtime.

Example

 Component {
     Rectangle {
         width: 50
         height: 50
         color: "red"
     }
     Rectangle {
         width: 50
         height: 50
         color: "blue"
     }
 }

To fix this warning, make sure the component has exactly one child. If it is empty, add a child to it. If it contains multiple, either remove the excess children, or wrap the children into a single top-level child of the component.

 Component {
     Item {
         Rectangle {
             width: 50
             height: 50
             color: "red"
         }
         Rectangle {
             width: 50
             height: 50
             color: "blue"
         }
     }
 }