[Interest] Qml plugin which registers at the same time C++ items and Qml files from resources.

Tomasz Olszak olszak.tomasz at gmail.com
Tue Jul 12 10:59:22 CEST 2016


Let's consider following use case:

1. Qml C++ plugin which registers C++ classes to Qml engine
2. It also has Qml files compiled in


module MyCompany.MyModule

plugin MyModule

classname MyModulePlugin




In MyModulePlugin::registerTypes(...):

// Register some C++ classes


// Register Qml files from resources

qmlRegisterType(QUrl("qrc:/MyCompany/MyModule/Item1.qml"), uri, 1, 0, "Item1");

qmlRegisterType(QUrl("qrc:/MyCompany/MyModule/Item2.qml"), uri, 1, 0, "Item2");

So as I understand above function corresponds to qmldir entry:

Item1 1.0 Item1.qml


How to register javascript files using such approach. In qmldir it can
be done like:

JsFile 1.0 JsFile.js

But following:

qmlRegisterType(QUrl("qrc:/MyCompany/MyModule/JsFile.js"), uri, 1, 0, "JsFile");

registers JsFile as attached property and I can't use functions from JsFile.js.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160712/f8009357/attachment.html>

More information about the Interest mailing list