Details
Description
These findings resolved out of the discussions here:
https://codereview.qt-project.org/c/qt/qtdeclarative/+/488122/3/examples/quickcontrols/filesystemexplorer/qml/FileSystemView.qml
The motivation that led to this investigation where 'Unqualified access' warnings generated by qmllint. The reproducer Project consists of the following structure:
. ├── CMakeLists.txt ├── instance.h // QML singleton ├── InstanceOk.qml ├── main.cpp ├── Main.qml ├── qmldir // For qmake compatibillity └── subdir └── InstanceNok.qml
'instance.h' QML-Singleton simply contains an invokable function named "printHello" that is called from Main.qml, InstanceOk.qml and InstanceNok.qml.
As the names point out, the file "InstanceNok.qml" will produce the Unqualified access warning:
// subdir/InstanceNok.qml import QtQuick.Controls import Instance TextArea { id: navigation anchors.fill: parent text: Instance.printHello() } // produces with: ninja all_qmllint: Info: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/InstanceOk.qml:2:1: Unused import [unused-imports] import Instance ^^^^^^ Info: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/subdir/InstanceNok.qml:2:1: Unused import [unused-imports] import Instance ^^^^^^ Warning: /home/qtwayn/Qt/qt6/qtdeclarative/examples/quickcontrols/filesystemexplorer_bugfind/subdir/InstanceNok.qml:7:11: Unqualified access [unqualified] text: Instance.printHello() ^^^^^^^^
However, if we rename the qmldir file to something else, like: qmldir_bkp and run the command: 'ninja all_qmllint' again everything is quiet and no warnings are emitted.
We use these 'handcrafted' qmldir files all around Qts examples to enable support for qmake.
Please find a minimal example attached.