How to create a quick plugin with a dot "." in the "URI"
-
After you create a Qt Quick 2 Extension plugin in qtcreator with cmake as the build system (let the project name to be MyDemo and check the Create example project checkbox ),
Then, you will get something like this in the CMakeLists.txt:qt_add_library(MyDemo STATIC) qt_add_qml_module(MyDemo URI MyDemo VERSION 1.0 QML_FILES MyItemControls.qml SOURCES myitem.cpp myitem.h )After that, if you change the
URI MyDemotoURI My.Demo, the exmaple subproject can not be compiled successfully.no matter changing the
qmldirfile in the project root or not, the example project can not be compiledSo, how to define a Quick extension plugin with an
URIwhich contains a dot likeMy.Module.UI? -
After you create a Qt Quick 2 Extension plugin in qtcreator with cmake as the build system (let the project name to be MyDemo and check the Create example project checkbox ),
Then, you will get something like this in the CMakeLists.txt:qt_add_library(MyDemo STATIC) qt_add_qml_module(MyDemo URI MyDemo VERSION 1.0 QML_FILES MyItemControls.qml SOURCES myitem.cpp myitem.h )After that, if you change the
URI MyDemotoURI My.Demo, the exmaple subproject can not be compiled successfully.no matter changing the
qmldirfile in the project root or not, the example project can not be compiledSo, how to define a Quick extension plugin with an
URIwhich contains a dot likeMy.Module.UI?@Sauntor You use the dot notation to reflect your project structure. If you have the following project structure: MyDemo/InnerMyDemo. In the
CMakeLists.txtinside youInnerMyDemodir you can have:add_library(InnerMyDemoLib) qt_add_qml_module(InnerMyDemoLib URI MyDemo.InnerMyDemoLib .... )Look at: https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html, https://doc.qt.io/qt-6/qtqml-writing-a-module.html
Note: If you don't want to reflect your project structure there's some CMake variable to define your custom layout. Look at: https://doc.qt.io/qt-6/qtqml-writing-a-module.html#custom-directory-layouts
-
@Sauntor You use the dot notation to reflect your project structure. If you have the following project structure: MyDemo/InnerMyDemo. In the
CMakeLists.txtinside youInnerMyDemodir you can have:add_library(InnerMyDemoLib) qt_add_qml_module(InnerMyDemoLib URI MyDemo.InnerMyDemoLib .... )Look at: https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html, https://doc.qt.io/qt-6/qtqml-writing-a-module.html
Note: If you don't want to reflect your project structure there's some CMake variable to define your custom layout. Look at: https://doc.qt.io/qt-6/qtqml-writing-a-module.html#custom-directory-layouts
-
S Sauntor has marked this topic as solved on
-
S Sauntor has marked this topic as solved on