- Qt 6.11
- Qt Qml
- Qt Qml Tooling
- qmllint
- QML Lint Warning and Errors
- Syntax
- Qt 6.11.2 Reference Documentation

Signal handler parameters ◦ Duplicate id

# Syntax

This warning category is spelled `[syntax]` by qmllint.

## Nested inline components are not supported

### What happened?

You defined an inline component inside another inline component.

### Why is this bad?

The QML language does not allow nested inline components. Always define inline components inside the root item of the QML file.

### Example

     import QtQuick

     Item {
         component Correct: Item {
             component Evil: Item { ... }
             ...
         }
     }

To fix this warning, move all components to the root item of the QML file.

     import QtQuick

     Item {
         component NotEvilAnymore: Item { ... }
         component Correct: Item {
             ...
         }
     }

## Inline component declaration must be followed by a typename

### What happened?

You defined an inline component with an invalid base type.

### Why is this bad?

Inline components need a base type to inherit from.

### Example

     import QtQuick

     Item {
         property Item someProperty
         component InlineComponent: someProperty {}
     }

In this case, `someProperty` is not a valid type name, as it is a property name. To fix this warning, use a valid Type as the component's base type:

     import QtQuick

     Item {
         property Item someProperty
         component InlineComponent: Item { ... }
     }

## Invalid alias expression: an initializer is needed

### What happened?

You defined a property alias without its aliased property.

### Why is this bad?

Alias properties always need to have their aliased property or id in their definition.

### Example

     import QtQuick

     Item {
         id: root
         property int someProperty
         property alias aliasProperty
     }

To fix this warning, replace the alias with a normal property, or add the missing aliased property:

     import QtQuick

     Item {
         id: root
         property int someProperty
         property alias withAliasedProperty: root.someProperty
     }

## Invalid alias expression: only ids and field member expressions can be aliased

### What happened?

You defined a property alias that aliases an expression other than an ID or a field member expression.

A field member expression is an expression of the form `someId.someProperty`.

### Why is this bad?

Alias properties always need to have their aliased property in their definition, and can't bind to other expressions than IDs and field member expressions.

### Example

     import QtQuick

     Item {
         property int p
         property alias someProperty: p + 1
     }

To fix this warning, replace the alias with a normal property or bind it to an id or field member expression:

     import QtQuick

     Item {
         id: root
         property int p
         property int someProperty: p + 1
         property alias alternative: root.p
     }

## Id must be followed by an identifier

### What happened?

You defined an id without a value.

### Why is this bad?

The QML language does not allow empty ids.

### Example

     import QtQuick

     Item {
         id:;
     }

To fix this warning, bind the id to a valid name:

     import QtQuick

     Item {
         id: root;
     }

## Failed to parse id

### What happened?

You bound an id to an expression other than a name.

### Why is this bad?

The QML language only allows names as bindings to ids; more complex expressions can't be used.

### Example

     import QtQuick

     Item {
         property int a
         property int b
         function f() {
             if (true)
                 return a
             return b
         }

         id: f()
     }

To fix this warning, bind the id to a valid name or declare a property and set up a binding:

     import QtQuick

     Item {
         property int a
         property int b
         function f() {
             if (true)
                 return a
             return b
         }

         id: someItem // it would be confusing to call it `f` like the function
         property int alternative: f()
     }

## Declaring an object which is not a QML object as a list member

### What happened?

You added an expression other than an object into a list of objects.

### Why is this bad?

The QML language only allows objects in object lists.

### Example

     import QtQuick

     Item {
         property int hello
         property list<Item> myList: [
             Item {}, hello{}
         ]
     }

To fix this warning, use a valid object type, or remove the item from the list:

     import QtQuick

     Item {
         component Hello: Item {}
         property list<Item> myList: [
             Item {}, Hello{}
         ]
     }

## Enums declared inside of inline components are ignored

### What happened?

You defined an enum inside an inline component.

### Why is this bad?

The QML language only allows enum definitions inside the root item of the QML file. Enums declared inside an inline component are unusable, even inside the inline component. The same applies to enums declared inside non-root QML objects.

### Example

     import QtQuick

     Item {
         component MyInlineComponent: Item {
             enum MyEnum { Hello, World }
         }
     }

To fix this warning, move the enum declaration into the root element of the QML file:

     import QtQuick

     Item {
         enum MyEnum { Hello, World }
         component MyInlineComponent: Item {
         }
     }

## Unknown argument to pragma

### What happened?

You specified an invalid argument to a pragma.

### Why is this bad?

The pragma will have no effect.

### Example

     pragma ComponentBehavior: Buond
     import QtQuick

     Item {
     }

You can fix this warning by removing the pragma or fixing a potential typo:

     pragma ComponentBehavior: Bound
     import QtQuick

     Item {
     }

Signal handler parameters ◦ Duplicate id