- Qt 6.11
- Qt Qml
- Qt Qml Tooling
- qmllint
- QML Lint Warning and Errors
- Incompatible type
- Qt 6.11.1 Reference Documentation

Warnings occurred while importing ◦ Inheritance cycle

# Incompatible type

This warning category is spelled `[incompatible-type]` by qmllint.

## Cannot assign to default property of incompatible type

### What happened?

You assigned an object to a default property of an incompatible type.

### Why is this bad?

The QML engine will not be able to assign the object at runtime.

### Example

     import QtQuick

     Item {
         component MyType: QtObject {
             default property list<Item> myDefaultProperty
         }

         MyType {
             QtObject {} // note: QtObject does not inherit from Item
         }
     }

To fix this warning, bind a compatible type to the property or, if you are the author of the default property, change the type in the definition:

     import QtQuick

     Item {
         component MyType: QtObject {
             default property list<Item> myDefaultProperty
         }

         MyType {
             Item {}
         }

         component AlternativeMyType: QtObject {
             default property list<QtObject> myDefaultProperty
         }

         AlternativeMyType {
             QtObject {} // is ok for AlternativeMyType
         }
     }

## On-binding for property has wrong type

### What happened?

You used an invalid property modifier type.

### Why is this bad?

The QML engine will not be able to use the property modifier type at runtime.

### Example

     import QtQuick

     Item {
         property int xxx
         Item on xxx { ... }
     }

To fix this warning, remove the `on` or use a valid property modifier type:

     import QtQuick

     Item {
         property int xxx
         Item { ... }

         // Alternative: use a valid property modifier type
         NumberAnimation on xxx { ... }
     }

## Construction from string is deprecated; Use structured value type construction instead

### What happened?

You constructed a QML_STRUCTURED_VALUE using a string.

### Why is this bad?

This is deprecated and prone to typos.

### Example

     import QtQuick

     Item {
         property point p: "5, 6"
     }

To fix this warning, populate the structured value type as explained in the QML_STRUCTURED_VALUE description instead of binding a string to the property:

     import QtQuick

     Item {
         property point p: ({ x: 5, y: 6 })
     }

## Function without return type annotation returns

### What happened?

You returned a value from a function without return type annotation.

### Why is this bad?

You annotated the function to not return anything so the function should not return anything. The QML tooling will not be able to process the method and the QML engine will ignore the returned value in a future Qt version.

### Example

     import QtQuick

     Item {
         function f(x: int) {
             ...
             return x
         }
     }

To fix this warning, adapt the function signature to the new return type or remove the return value:

     import QtQuick

     Item {
         function f(x: int): int {
             ...
             return x
         }
         function alternativeF(x: int) {
             ...
             return
         }
     }

## Cannot assign binding/object/literal

### What happened?

You bound an object, literal, or expression to a property of an incompatible type.

### Why is this bad?

The QML engine will not be able to assign the object, literal, or expression at runtime.

### Example

     import QtQuick

     Item {
         property date xxx: 42
     }

To fix this warning, bind an object, value, or expression of a compatible type:

     import QtQuick

     Item {
         property date xxx: new Date()
     }

Warnings occurred while importing ◦ Inheritance cycle