[Development] qqmlengine/qqmlimport access

mark diener rpzrpzrpz at gmail.com
Fri May 29 17:53:47 CEST 2015


Hello dev list:

Qt 5.4.1.

At the top of qqmlimport_p.h, it discusses how it is NOT part of the QT API
and subject to change.

In qqmlengine.h, there is addImportPath( ) to allow qqmlimport to resolve
types using a module/qmldir file.

But ByteArray derived components have no equivalent treatment:


QByteArray gbytes("import QtQuick 2.4\n Rectangle {
objectName:\"myRecto\"\n color: \"blue\" }");

QQmlComponent gcomponent(&gengine) ;

gcomponent.setData(gbytes,QUrl("Myrectangle.qml"));


How to add the QQmlComponent in the QQmlEngine import database so that
QQmlImports::addImplicitImport( ) can resolve component type?

There is no new C++ type here, just a new component defined in QML, so
qmlRegisterType<C++type>(bla,bla,bla) is a fail.

Or maybe there is a non-qmldir file method to use importExtension with
QQmlComponent?  (qmldir file alternative)

Does QQmlEngine have a public access way to achieve the following:

QQmlEngine::addImportComponent(QString gname,QQmlComponent& gcomponent) ;
QQmlEngine::removeImportComponent(QString gname) ;

In QML, I could either have an importExtension()  OR an implicitImport() in
qqmlimports.

Thanks,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150529/cd6fa4cf/attachment.html>


More information about the Development mailing list