Details
-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.8.3
-
None
Description
When using the optional chaining (?.) and nullish coalescing (??) operators to safely access properties of QVariant/QVariantMap type in QML, false warnings are reported by the code analyzer:
Cannot load property variable from dict with type QVariant Cannot load property variable from QVariant
Despite these warnings, the code runs correctly at runtime and behaves as expected—the operators correctly guard against null/undefined access.
Example Code:
Item { property var dict: ({variable: "value"}) readonly property string dictVariable: dict?.variable ?? "" // Warning: Cannot load property variable from dict with type QVariant Component.onCompleted: { console.log(dict?.variable ?? "") // Warning: Cannot load property variable from QVariant } }
The issue does also occur when the type is explicitly annotated as QVariantMap on the C++ side and exposed with Q_PROPERTY