[Interest] Role of `qmlscene` and `qml` command line tools

Elvis Stansvik elvstone at gmail.com
Fri May 6 15:16:45 CEST 2016


2016-05-06 13:34 GMT+02:00 Shawn Rutledge <Shawn.Rutledge at qt.io>:
>
>> On 6 May 2016, at 13:07, Elvis Stansvik <elvstone at gmail.com> wrote:
>>
>> [estan at pyret ~]$ qml test.qml -- --foo bar
>> qml: /usr/lib/qt/bin/qml,test.qml,--,--foo,bar
>> [estan at 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)
>
> Not really, AFAIK.  QCommandLineParser is kindof new itself (umm since 5.2… tempus fugit).  It would be interesting to come up with a nice declarative API for that.  It would probably need a QObject or Q_GADGET wrapper since QCommandLineParser isn’t either one, and has an imperative API.  But I wonder how many people would use it.
>
> Running any kind of script directly without looking at it first requires some trust, so maybe that’s why it hasn’t been in high demand to use QML that way, so far.  Or else it’s just lack of habit, and lack of advertising that you could do that.

Alright, I see. There's probably some JS lib out there I could use,
after stripping everything after Qt.application.arguments[0] up to and
including the '--'.

The point about trust is valid for any application though, isn't it?
What's special about "here you go, run `qml main.qml`" compared to
"here you go, compile main.cpp and run it"? In both cases the user
must choose to trust the code. Or maybe I misunderstood you?

Another thing I realized is that my instructions to other devs for
working with Qt Creator becomes slightly more complicated. They'll go
from just

1. Open foo.pro in Qt Creator.
2. Edit the Run Environment to set PYTHONPATH.
3. Ctrl+R

to

1. Open foo.pro in Qt Creator.
2. Add a new Custom Executable run configuration under Projects ->
Run, to run `qml main.qml`.
3. Edit the Run Environment to set PYTHONPATH
4. Uncheck [X] Always build project before deploying it in Option ->
Build & Run.
5. Ctrl+R

But it's not that bad.

Anyway, thanks for the input. I also had a look at the config file
that `qml` uses, and it seems that what is shown in the default config
is pretty much all there is.

Elvis



More information about the Interest mailing list