Alias-Zyklus
Diese Warnkategorie wird von qmllint als „ [alias-cycle] “ bezeichnet.
Die Alias-Eigenschaft ist Teil eines Alias-Zyklus
Was ist passiert?
Ein Eigenschaftsalias verweist auf sich selbst oder auf einen anderen Alias, der wiederum auf sich selbst verweist.
Normalerweise sollte ein Eigenschaftsalias entweder direkt oder indirekt über eine andere Aliaseigenschaft auf eine andere Eigenschaft verweisen.
Wenn ein Alias direkt oder indirekt auf sich selbst verweist, entsteht ein Aliaszyklus. Die Warnung weist darauf hin, dass sich die aktuelle Alias-Eigenschaft innerhalb eines Aliaszyklus befindet oder auf einen solchen verweist, siehe Beispiel.
Warum ist das problematisch?
Instanzen von Komponenten mit Aliaszyklen werden zur Laufzeit nicht erstellt: Stattdessen sind sie null.
Beispiel
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
}Um diese Warnung zu beheben, lösen Sie die Aliaszyklen auf:
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
}© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.