[Qt-qml] Using C++ plugin with QML loaded from application resources...

ray.rischpater at nokia.com ray.rischpater at nokia.com
Fri May 6 00:22:44 CEST 2011


Hi!

This seems like this should work, but I'm not able to use a pre-written C++ plugin for QML with another C++ app that draws its QML from its resource file. (The same plugin works fine if I use QML loaded from the file system, however.)

In its simplest form, if I do this in my test app, my plugin is found and the QML displays an instance of the view class in my C++ plugin:
    engine()->addPluginPath("C:/work/sandbox/test-app-build-desktop/qml/test-app");
    setSource("qrc:/qml/mostest-app/main.qml");
The plugin's at the directory I specify in the first line; it's a directory with the same name as the name of the plugin in my QML import directive.

If, however, I flip over to loading the same content from the application resource, like this:
    engine()->addPluginPath("C:/work/sandbox/test-app-build-desktop/qml/test-app");
    setSource("qrc:/qml/mostest-app/main.qml");
The import in my QML fails.

Setting QML_IMPORT_TRACE, the first example shows things are loading:
C:\work\mosmapplugin-sandbox\mostest-app-build-desktop\debug\mostest-app.exe exited with code 0
Starting C:\work\mosmapplugin-sandbox\mostest-app-build-desktop\debug\mostest-app.exe...
QDeclarativeImportDatabase::addImportPath: "C:\Qt\4.7.2-vs\imports"
QDeclarativeImportDatabase::addImportPath: "C:/work/sandbox/test-app-build-desktop/debug"
QDeclarativeImportDatabase::addPluginPath: "C:/work/sandbox/mostest-app-build-desktop/qml/mostest-app"
QDeclarativeImports(file:///C:/work/sandbox/test-app-build-desktop/qml/test-app/main.qml)::addImport: "." -1.-1 File as ""
QDeclarativeImports(file:///C:/work/sandbox/test-app-build-desktop/qml/test-app/main.qml)::addImport: "QtQuick" 1.0 Library as ""
QDeclarativeImports(file:///C:/work/sandbox/test-app-build-desktop/qml/test-app/main.qml)::addImport: "MyPlugin" -1.-1 File as ""
QDeclarativeImports(file:///C:/work/mapplugin-sandbox/test-app-build-desktop/qml/test-app/main.qml::importExtension: loaded "C:/work/sandbox/test-app-build-desktop/qml/test-app/MyPlugin/qmldir"
QDeclarativeImportDatabase::importPlugin: "C:.work.sandbox.test-app-build-desktop.qml.test-app.MyPlugin" from "C:/work/sandbox/test-app-build-desktop/qml/test-app/MyPlugin/MyPlugin.dll"
(debugging continues)
But the second is not:
QDeclarativeImportDatabase::addImportPath: "C:\Qt\4.7.2-vs\imports"
QDeclarativeImportDatabase::addImportPath: "C:/work/sandbox/test-app-build-desktop/debug"
QDeclarativeImportDatabase::addPluginPath: "C:/work/sandbox/test-app-build-desktop/qml/test-app"
QDeclarativeImports(qrc:/qml/test-app/main.qml)::addImport: "." -1.-1 File as ""
QDeclarativeImports(qrc:/qml/test-app/main.qml)::addImport: "QtQuick" 1.0 Library as ""
QDeclarativeImports(qrc:/qml/test-app/main.qml)::addImport: "MyPlugin" -1.-1 File as ""
qrc:/qml/test-app/main.qml:2:1: "MyPlugin": no such directory

So, the question is: is this supposed to work? If so, what am I doing wrong? And if not, why not?

Thanks,
Ray Rischpater
Nokia Research Center Palo Alto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110505/08cab6f5/attachment.html 


More information about the Qt-qml mailing list