Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Cannot access singleton as a property of an object

Access singleton via object

What happened?

You accessed a singleton using the syntax for accessing attached properties from a namespace.

Why is this bad?

Singletons can't be accessed in this way. The expression will evaluate to undefined.

Example

import QtQml
import QtQuick as QQ

QtObject {
    id: root
    // Cannot access singleton as a property of an object. Did you want to access an attached object?
    property var singletonAccess: root.QQ.Application.platform
}

To fix this warning, remove the id or property in front of the namespace if you intended to use the singleton. Alternatively, check for typos if you wanted to access an attached property.

import QtQml
import QtQuick as QQ

QtObject {
    id: root
    property var singletonAccess: QQ.Application.platform
    property bool attachedPropertyAccess: root.QQ.ListView.isCurrentItem
}
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded