[Interest] Wrapping a .qml file into a Qt plugin?

Guido Seifert wargand at gmx.de
Fri Nov 1 02:59:31 CET 2013


On Thu, 31 Oct 2013 09:33:42 -0700
Alan Alpert <416365416c at gmail.com> wrote:

> Add the qml files as a resource, then use
> https://qt-project.org/doc/qt-5.1/qtqml/qqmlengine.html#qmlRegisterType-3
> to register them into the plugin's module.


Does not seem to work. At least not as easy as I hoped it would. I put qml 1 as resource 
in my QQmlExtensionPlugin. I register it in registerTypes: 

void SpeedPlugin::registerTypes(const char *uri){
	QUrl u("qrc:/SpeedQMLFiles/SpeedMain.qml");
	qmlRegisterType(u, uri, 1, 0, "Speed");
}

This _seems_ to work. I can load the plugin using the PluginLoader. I can call register and with
QML_IMPORT_TRACE=1 it looks like my qml is correctly registered.

Unfortunately I cannot use it. When I import Speed into qml 2, I get:
qrc:/SpeedQMLFiles/SpeedMain.qml: File not found

The 'main' qml cannot access the resources of my plugin. Ok, not too surprising. It
was worth a try.

Guido




More information about the Interest mailing list