Maybe i did not cleary note at question: I placing all qml files related to module (main.qml, Style.qml) into "qml" subdirectory (it was working until i try to use singletons) If i add ".qml" to the URI then QQmlApplicationEngine fails to load component from either QUrl url1(u"qrc:/untitled/qml/main.qml"_qs), url2(u"qrc:/untitled/main.qml"_qs)
CMakeLists.txt: ... qt_add_executable(untitled main.cpp ) set_source_files_properties(Style.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) qt_add_qml_module(untitled URI untitled.qml VERSION 1.0 QML_FILES qml/main.qml qml/Style.qml ) ... On Tue, Mar 7, 2023 at 2:55 PM Ulf Hermann via Interest < interest@qt-project.org> wrote: > > Qt 6.4.2 QML singleton's properties undefined if singleton QML file > > placed in subdirectory e.g "/qml" (${CMAKE_SOURCE_DIR}/qml/Style.qml) > > You should not place your QML files in a different directory than the > module (as denoted by the generated qmldir file). Otherwise their > implicit import is not the same as the module they belong to, which then > leads to effects like this. > > The implicit import is the way you can use QML components placed in .qml > files in the same directory without importing anything. > > The component in question is a singleton in the module since it has a > "singleton" line in the qmldir. It is, however, a regular non-singleton > component in the implicit import since the implicit import does not see > the qmldir. > > You can move the whole QML module into the "qml" subdirectory and add > ".qml" to the URI to avoid this. Or you can move all the .qml files into > the base directory of the module. > > best regards, > Ulf > _______________________________________________ > Interest mailing list > Interest@qt-project.org > https://lists.qt-project.org/listinfo/interest >
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest