2016-05-06 12:50 GMT+02:00 Shawn Rutledge <[email protected]>:
>
>> On 6 May 2016, at 11:36, Elvis Stansvik <[email protected]> wrote:
>>
>> Hi all,
>>
>> Since some time, the `qmlscene` command has been available for
>> debugging QML applications:
>>
>> …
>> Recently, the `qml` command is also available:
>>
>> The tools seem quite similar. What was the rationale for introducing
>> `qml`? The old `qmlscene` is described in the docs [1] as:
>>
>> "The qmlscene utility is meant to be used for testing your QML
>> applications, and not as a launcher in a production environment. To
>> launch a QML application in a production environment, develop a custom
>> C++ application or bundle the QML file in a module. See Deploying QML
>> applications for more information."
>>
>> Is there a similar page describing the `qml` tool somewhere (I can't
>> see it mentioned anywhere)? Is the `qml` tool also meant only for
>> testing/debugging, and not for production use?
>
> The QML tool is a bit more flexible, makes fewer assumptions (e.g. it doesn’t
> use a QApplication by default, so you don’t end up loading the widgets module
> into memory if you don’t need it) and is meant as the long-term replacement
> for qmlscene. QML can be used for non-graphical purposes if your root object
> is a plain QObject, not an Item or Window; that’s only practical with the qml
> tool, not qmlscene. It is more directly analogous to other language
> interpreters like python and perl (which also do not load graphical libraries
> unless you import the relevant modules in your script), and you can even use
> the shebang mechanism, so that qml files can be marked executable and run
> from the command line. You can configure your window system to use it as the
> default application with which to run any file with the qml extension (e.g.
> when double-clicking a qml file in your file manager/finder), if you like.
> (QTBUG-33659 is a request to set up that association when you install the
> SDK, but that never got done AFAIK. It requires someone with Qt Installer
> expertise, I think.)
>
> Here’s one of Alan’s talks, shortly after he wrote it:
>
> https://www.youtube.com/watch?v=2nnrl1v7LcE
>
> So you could nearly forget about qmlscene, except that it has a few handy
> command-line options that qml still doesn’t. OTOH qml can be configured via
> config files. And yes I think that should be documented better. You can see
> the default configuration in tools/qml/conf/configuration.qml, but it’s not
> clear enough what else could be declared in your custom config file.
>
>> The reason I'm asking is I'm building a QML application for embedded
>> use. The app is QML only, apart from some calls from QML into Python
>> using pyotherside [2] when interfacing with the hardware. So in theory
>> I could launch my app using `qmlscene` or `qml`, which would free me
>> from having to build and distribute a little C++ launcher application
>> to launch the app.
>
> That’s what the qml tool is intended for.
Thanks for the clarifications Shawn! Launching our app through `qml`
seems the way to go then.
One question regarding command line arguments though:
[estan@pyret ~]$ cat test.qml
import QtQuick 2.4
Rectangle {
width: 30
height: 40
color: "blue"
Component.onCompleted: {
console.log(Qt.application.arguments)
}
}
[estan@pyret ~]$ qml test.qml -- --foo bar
qml: /usr/lib/qt/bin/qml,test.qml,--,--foo,bar
[estan@pyret ~]$
Do you know if there's any QML API to get just the arguments following
"--"? Or I'll have to parse that out myself?
In general, is there any convenient QML API for command line parsing?
(e.g. like QCommandLineParser on the C++ side)
Elvis
>
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest