Unqualified Access

Unqualified Access

What happened?

A parent element was accessed without its id.

Why is this bad?

This makes the code harder to read and impedes performance.

Example

import QtQuick

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

You can fix this warning by referring to the parent object by id. If the object currently has no id, you will need to add one first.

import QtQuick

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

See also QML Coding Conventions - Unqualified Access.

© 2024 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.