1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qmllint-warnings-and-errors-required.html
6\ingroup qmllint-warnings-and-errors
8\title Component is Missing a Required Property
9\brief A component's required property was not bound.
11\section1 Component is Missing a Required Property
13\section2 What happened?
14The \l{QML Object Attributes#required-properties}{required property} of a component was not set.
17\section2 Why is this bad?
18QML applications where components miss required properties will misbehave: they will not
19start at all if a missing required property is detected statically. Dynamically created components
20with missing required properties will not be created at runtime: they will be null instead.
27 component RepeatMe: Item {
28 required property int index;
29 required property int helloWorld;
32 RepeatMe {} // not ok: required properties index and helloWorld not set
36 RepeatMe {} // not ok: required property index set by Repeater, but not helloWorld
40You can fix this warning by setting the required properties
45 component RepeatMe: Item {
46 required property int index;
47 required property int helloWorld;
53 } // ok: all required properties were set
58 helloWorld: index * 2 + 1
59 } // ok: all required properties were set: index by the Repeater and helloWorld by the user
64\sa {QML Coding Conventions#required-properties}{QML Coding Conventions - Required Properties}