QML , imports and library/project organization
-
Hi all,
I am trying to design a project structure for my future qt/qml codebase.
My code usually consist of many small/medium size libraries and then I create applications using them. Basically all my code apart some few lines resides in libraries, including application code. I then compile them either statically or dynamically.Obviously there are many dependencies, and everything is managed in the .pri and .pro files, with the various INCLUDE_PATH and LIBS variables that point to the proper library dependencies.
This approach works quite well with standard C++ and also for QWidgets. I am trying to apply the same idea to QML and the cross-platform world, but even after reading the documentation, I am still experiencing issues.
The idea is to create libraries that both consist of QML and of manager C++ code.Just to let you understand better, this is the project structure I have in mind:
libA - source/libA.pri - source/libA.pro - source/header_files.h - source/cpp_files.cpp - source/qml/qml_files.qml - source/qml/qmldir - source/qml.qrc // ... libN - // same structure as libA App1 - // same structure as libA
Nothing is fixed, everything can change, but still this should be the basis. What it seems not working are the QML_IMPORT_PATH / QML2_IMPORT_PATH variables . Even if they point to the right path, import directives still do not work: "QML module not found". Apparently the only thing that seems working is the engine.addImportPath("my_paths") approach, fixed in the .cpp files.
What's your opinion about this approach? is there a way to just use .pri / .pro files to load QML from other libraries?