Description
I remember an example about it, but it disappeared after 0.5.
This is confusing to me what is the right way to write a "plugin" nowadays?
It seems cxx-qt is almost dealing with everything, all the symbols are generated, the QmlExtensionPlugin
class, the qmltypes
, etc... It just I don't understand how to make it a loadable plugin.
I'm happy with a cargo only build or a cmake based one.
Some use case
I want to introduce a new module to test cxx-qt for a cpp based project, but I want to make the changes as minimal as possible. So I thought the plugin approach sound nice.
What I've done so far
Everything I've tried is based of the qml_minimal
example
- cargo only: build a dynlib, move the dynlib file in the same folder as where
qmldir
is located. I getrust/target/debug/build/qml_minimal-b6d7b9673e0f279f/out/qt-build-utils/qml_modules/com/kdab/cxx_qt/demo/libcom_kdab_cxx_qt_demo.dylib' is not a Qt plugin
. - Many variant from CMake
- Write my own plugin:
qt_add_plugin(example_qml_minimal
cpp/plugin.cpp
)
target_link_libraries(example_qml_minimal PRIVATE qml_minimal_qml_module)
And in plugin.cpp
:
#include <QtQml/QQmlExtensionPlugin>
#include <QtQml/QQmlEngine>
#include <qml_minimal/src/cxxqt_object.cxxqt.h>
class CoreQmlpluginPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char* uri) override
{
qmlRegisterType<my_object::MyObject>(uri, 1, 0, "MyObject");
}
};
#include "plugin.moc"
The latter works, but then I'm loosing the benefit of what cxx-qt is doing: automation (qml_element) and tooling files (qmltypes)
Conclusion
I feel I'm missing an obvious step somewhere. Using the keyword plugin
doesn't yield any interesting issue here, or relevant doc in the book.
Metadata
Metadata
Assignees
Type
Projects
Status