[Development] QML Runtime

Alan Alpert 416365416c at gmail.com
Tue Dec 11 20:27:08 CET 2012

On Tue, Dec 11, 2012 at 8:00 AM, Thiago Macieira
<thiago.macieira at intel.com> wrote:
> On terça-feira, 11 de dezembro de 2012 10.48.43, Knoll Lars wrote:
>> > The main difficulty I see is how to determine which application class to
>> > instantiate.
>> >
>> > If you load a non-UI QML file you might not want QGuiApplication to be
>> > instantiated.
>> > If you load a QtQuick1 file you'll need QApplication instantiated.
> You can specify extra options in the hashbang line:
> #!/usr/bin/qml -t quick1
> #!/usr/bin/qml -t qbs

That's a good idea. qml could have a command line argument for what
application to start with, maybe more like -a [core,gui,widget] than
tied to a specific module.
>> I'd assume that the runtime will be limited to Qt Quick 2.
> If it's limited to Qt Quick 2, it shouldn't be called "qml". Call it
> "qtquick2" then.

The idea was that it's limited to QML 2, not QtQuick 2, and that's
only because QML 2 is the most recent version when the tool was
started. The point with the root Window{} item wasn't to restrict it
to QtQuick 2, it's just that we're now using functionality that the
limited QtQuick 1 API didn't expose.

Conceptually the way it works is that qml does nothing but load and
instantiate a QML file using the QML 2 engine (maybe it can have a
cmdline argument for the QML 1 engine). Theoretically this works with
all modules: QtQuick 2, QtQuick 1 and qbs alike. In practice this does
not work for QtQuick 1 because QtQuick 1 does not have an element
which can instantiate a top level window (like Window{}) and so there
is no way to take the instantiated tree of items and associate them
with a rendering surface. If it was that important, it's perfectly
valid conceptually to add a QQ1Window{} element to an addon which
instantiates an empty QtQuick 1 scene, and then qml would work with
QtQuick 1.

The only reason that the application needs to be chosen by command
line is that I don't think we can't add QML bindings to
QCoreApplication and friends, due to the QML engine depending on them.

Alan Alpert

More information about the Development mailing list