Equivalent of CONFIG+=qmltypes in CMake build?
-
Hello.
I just found out about the new way to expose C++ types to QML using the
QML_ELEMENTmacro, as described e.g. here.To test it with CMake builds, I converted the
Addingexample
Qt/Examples/Qt-5.15.0/qml/referenceexamples/adding
to a CMake project.While it runs fine when using the old way of registering the type with
qmlRegisterType<Person>("People", 1,0, "Person");it fails when commenting that line out (and uncommenting the
QML_ELEMENTmacro):QQmlComponent: Component is not ready (qrc:example.qml:52:1: module "People" is not installed import People 1.0 ^)I assume it has to do with not having used the CMake equivalent of the following
.proline:CONFIG+=qmltypesBut, what is the CMake equivalent of the above
CONFIGflag?Thanks for your help!
-
Hello.
I just found out about the new way to expose C++ types to QML using the
QML_ELEMENTmacro, as described e.g. here.To test it with CMake builds, I converted the
Addingexample
Qt/Examples/Qt-5.15.0/qml/referenceexamples/adding
to a CMake project.While it runs fine when using the old way of registering the type with
qmlRegisterType<Person>("People", 1,0, "Person");it fails when commenting that line out (and uncommenting the
QML_ELEMENTmacro):QQmlComponent: Component is not ready (qrc:example.qml:52:1: module "People" is not installed import People 1.0 ^)I assume it has to do with not having used the CMake equivalent of the following
.proline:CONFIG+=qmltypesBut, what is the CMake equivalent of the above
CONFIGflag?Thanks for your help!
@gillamkid, @Seboo
It seemsCONFIG+=qmltypesis not supported inCMakefor Qt 5 versions, but can be used in Qt 6, as described here:
https://stackoverflow.com/questions/63509161/how-to-use-qml-element-with-cmakeHave not tested it though.