Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a QML application to be launched by qmlscene. I want this to accept arguments, so I'm using the Arguments object. However, this gets the arguments passed to qmlscene as well as those I mean to pass to my program. More problematically, if one of the arguments is a file, qmlscene tries to process it, failing or hanging. Is there a good way around this problem?

The first thing I tried was to pass the arguments in as a specific named argument that qmlscene would ignore. The launch line looks like qmlscene -I <directory> <qml file> --appargs="$*". ($* is a bashism for all the arguments as a single string.) For a single argument, this works pretty well. But if I were to want to pass more than one argument in, I'd have to parse them myself, which sort of defeats the purpose of having an argument parser.

Looking at some sample .desktop files, I noticed they put the arguments before the qml file, so I tried a command line like qmlscene "$@" -I <directory> <qml file>. This does keep qmlscene from trying to interpret these arguments. But if I don't pass any arguments, the Arguments object will happily process the arguments meant for qmlscene. So I still have to do some processing here. I can't help but suspect I missing a better way. What is it?

share|improve this question suggests that there is a Qt.application.arguments property in Qt 5.1. I do not know whether this does what's required, though.

share|improve this answer
It looks like Qt.application.arguments will do roughly the same thing as my --appargs approach -- you just get a string with all the arguments. I don't know whether it will filter out the qmlscene arguments or not. Since Qt5.1 hasn't made it into Ubuntu yet, I can't test. – Robert Schroll Aug 31 '13 at 17:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.