[Interest] QQmlFileFilter and refering explicitly to a certain QML file

Jesper Hellesø Hansen jesperhh+qt at gmail.com
Thu Jan 14 11:46:47 CET 2016


Hi,

I am working on a project where we want to use QQmlFileFilter to load
different UIs for different products. It almost works as I want it to, but
I have one issue. Take the two files:

MyText.qml
+new/MyText.qml

As long as I re-implement MyText.qml in +new/MyText.qml everything just
works. What I would like to do instead is to implement the functionality I
want in MyText.qml and then only keep the "delta" in +new/MyText.qml, for
example like this:

import "../" as Base

Base.MyText {
    text: "+new text"
}

This does not work, Base.MyText will refer to +new/MyText.qml instead of
just MyText.qml.

One solution is to have a separate "Base" qml file that both the original
MyText.qml and +new/MyText.qml inherit , but I would like to avoid that if
possible.

Another solution is to put the "base" qml file in a +base folder, then I
can refer to the base version by doing import "+base" as Base. However,
because the QFileSelector wants the file without selectors to exist as well
(even if it is not used), I have to create an empty dummy file.

I have added my attempts to the repository
https://github.com/jesperhh/QmlFileSelectorTest if anyone wants to try them
out.

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160114/e55847d0/attachment.html>


More information about the Interest mailing list