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

Cannot access singleton as a property of an object ◦ Attached property reuse

# Alias cycle

This warning category is spelled `[alias-cycle]` by qmllint.

## Alias property is part of an alias cycle

### What happened?

A property alias resolves to itself or to another alias resolving to itself.

Usually, a property alias should reference another property either directly, or indirectly by passing through another alias property.

If a property alias directly or indirectly references itself, then it forms an alias cycle. The warning indicates that the current alias property is inside or references an alias cycle, see Example.

### Why is this bad?

Instances of components with alias cycles will not be created at runtime: they will be null instead.

### Example

     import QtQuick

     Item {
         id: someId
         property alias myself: someId.myself // not ok: referring to itself

         property alias cycle: someId.cycle2 // not ok: indirectly referring to itself
         property alias cycle2: someId.cycle

         property alias indirect: someId.cycle // not ok: referring to alias indirectly referring to itself
     }

To fix this warning, break up the alias cycles:

     import QtQuick

     Item {
         id: someId
         Item {
             id: anotherId
             property string myself
             property int cycle
         }
         property alias myself: anotherId.myself // ok: referring to a property

         property alias cycle: someId.cycle2 // ok: does not refer to itself anymore
         property alias cycle2: anotherId.cycle // ok: not a cycle anymore

         property alias indirect: someId.cycle // ok: cycle does not form an alias cycle anymore
     }

Cannot access singleton as a property of an object ◦ Attached property reuse