How to register a custom QML type in a visual studio project?
-
wrote on 9 Mar 2022, 05:02 last edited by
I'm trying to replicate the code in the tutorial Writing QML Extensions with C++ in a visual studio project (with Qt VS tools extension). But I can not find the correct way to register the newly created QML type.
Inside the tutorial, it's using qmake code blow to register the QML type:
CONFIG += qmltypes QML_IMPORT_NAME = Charts QML_IMPORT_MAJOR_VERSION = 1
But I didn't find the counterpart settings inside the visual studio project settings, and extra qmake commands are not found either. How could I register the type?
-
wrote on 9 Mar 2022, 10:44 last edited by
Well, is it even possible?
-
wrote on 9 Mar 2022, 20:38 last edited by
The 5.15 way is very inflexible. I don't like it at all.
https://doc.qt.io/qt-5/qqmlengine.htmlYou would do better finding the docs for 5.12 for how to register qml types. It shows how to use qqmlengine better. [https://doc.qt.io/archives/qt-5.12//qtqml-tutorials-extending-qml-example.html(https://doc.qt.io/archives/qt-5.12//qtqml-tutorials-extending-qml-example.html).
As far as I know the "new way" is not going to replace the "old way".
We register multiple QML modules that we define. I struggled to see how to do that with the new way.
-
wrote on 10 Mar 2022, 04:48 last edited by ShenC 3 Oct 2022, 05:06
It works with the function
qmlRegisterType
. Literally appreciate your help @fcarney . It had bothered me quite a lot.
1/4