0

I want to create a CMake project that contains only a QML (dll/dylib or static) library (resources included). My idea is to create a core QML library with all my stuff (custom components, style, theme, core icons, etc) and import it when needed in all my projects (like a .lib or a dll/dylib). At the same time, I would not want to change the components resources path in the top level project. I'm using Qt DesignStudio and Qt Creator for Qt 6.2.x.

Right now, I have created a folder into the import folder, adding this in the CMakeLists.txt

add_subdirectory(MyFrontEndCoreLib)

Then, I have added a UICoreComponents and an Image folders into MyFrontEndCoreLib folder. The CMakeLists.txt file into the UICoreComponents is the following:

qt_add_library(MyFrontEndCoreLib_UICoreComponents STATIC)
qt6_add_qml_module(MyFrontEndCoreLib_UICoreComponents
    URI "MyFrontEndCoreLib.UICoreComponents"
    VERSION 1.0
    QML_FILES
        IconLabel.qml
        BorderedRectangle.qml
        MyButton.qml

)

But I have no clue how to include this code/files into a library.

Thank you in advance

  • Does this answer your question? [How create shared library in QT/QML](https://stackoverflow.com/questions/40968813/how-create-shared-library-in-qt-qml) – folibis Jan 03 '23 at 10:31
  • Note, the link that @folibis refers to is for Qt5. Since you're using Qt6, the process is different. – JarMan Jan 03 '23 at 15:08
  • It looks to me like you are already creating a library with the code that you have shown. You've created a library called MyFrontEndCoreLib_UICoreComponents and add 3 QML files to it. So I'm not clear what part you are having difficulty with? – JarMan Jan 03 '23 at 15:12
  • @JarMan yes I have created this module under the imports folder of a Application project. I want to export this module as a library in order to use it in a different project which includes even some backend c++ libraries. – Messerdodo Jan 03 '23 at 16:20

0 Answers0