Unqualified

This warning category is spelled [unqualified] by qmllint.

Unqualified access

What happened?

You accessed a parent element without its id .

Why is this bad?

This makes the code harder to read and impedes performance.

范例

import QtQuick
Item {
    property int helloWorld
    Item {
        property int unqualifiedAccess: helloWorld + 1 // not ok: Unqualified access here.
    }
}
					

To fix this warning, refer to the parent object by id . You will need to add an id first if the object currently has none.

import QtQuick
Item {
    id: root
    property int helloWorld
    Item {
        property int unqualifiedAccess: root.helloWorld + 1 // ok: this access is qualified now!
    }
}
					

Unknown attached/grouped property scope

What happened?

You used an attached property type or grouped property that can't be found. This can be caused by a typo or by a missing QML module dependency.

注意: If you are importing QML modules with external dependencies, verify that they are actually installed and inside an import 路径 .

Why is this bad?

Components with unknown attached property scopes or unknown grouped properties will not be created at runtime: they will be null instead.

范例

Let's try to use the (inexistent) attached property of Item or the (inexistent) grouped property grouped of Item :

import QtQuick
Item {
    Item.helloAttached: 44 // not ok: unknown attached property scope Item. [unqualified]
    grouped.helloGrouped: 44 // not ok: unknown grouped property scope grouped. [unqualified]
}
					

Indeed, Item does neither have any attached type nor any grouped property called item . To fix this warning, remove the attached type and the grouped property.

参考 附加特性和附加信号处理程序 on how to use attached properties and to 分组特性 on how to use grouped properties.

No matching signal found for handler

What happened?

You used a 信号处理程序 on a signal that can't be found. This can be caused by a typo in the signal handler or by a missing QML module dependency.

注意: The name of a signal handler is on concatenated with the capitalized signal name. onHelloWorld handles the signal helloWorld and on_helloWorld 处理 _helloWorld ,例如。

注意: If you are importing QML modules with external dependencies, verify that they are actually installed and inside an import 路径 .

Why is this bad?

Components with unknown signal handlers will not be created at runtime: they will be null instead.

范例

Lets try to write a signal handler for the (inexistent) signal mySignal :

import QtQuick
Item {
    onMySignal: console.log("hello") // not ok: no matching signal found for handler "onMySignal" [unqualified]
}
					

Indeed, this Item does not have any signal called mySignal . To fix this warning, remove the signal handler or add the missing signal.

Implicitly defining signal handler in Connections is deprecated

What happened?

You used a signal handler on a Connections 类型。

Why is this bad?

This is deprecated.

范例

import QtQuick
Window {
    id: root
    property int myInt
    Connections {
        target: root
        onMyIntChanged: console.log("new int", myInt)
    }
}
					

To fix this warning, replace the signal handler binding with a function:

import QtQuick
Window {
    id: root
    property int myInt
    Connections {
        target: root
        function onMyIntChanged() { console.log("new int", myInt) }
    }
}
					

另请参阅 QML Coding Conventions - Unqualified Access .