-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.5.0
-
None
doc link : https://doc.qt.io/qt-6/qtqml-syntax-directoryimports.html#the-implicit-import
I think for the Note, we should add the following example to make it clear.
*This is my interpretation of what's written. Please correct it accordingly.
----------------------
Let's say the directory is structured as follows. project_dir |-a.qml |-qmldir |-subdir |-b.qml |-c.qml This is a bad case. The qmldir defines a module contains b.qml and c.qml and c.qml is declared as singleton. The a.qml imports this module. What happens is in a.qml, c.qml is correctly treated as singleton, but b.qml, which implicitly imports c.qml in the same directory, doesn't treat c.qml as a singleton. Therefore, c.qml is treated as singleton in one place but not in the other. However, in this good example below, in both a.qml and b.qml, c.qml is treated as singleton, because a.qml imports a module defined in qmldir, so that it's aware of the fact that c.qml is declared as singleton. Also since b.qml is aware of the qmldir in the same directory, it automatically treats c.qml as singleton too. As a result, c.qml is treated as singleton in all the places it's used. project_dir |-a.qml |-subdir |- b.qml |- c.qml |-qmldir