[Qt-qml] Disable initial qmlviewer warning + console.print() to STDOUT

Alan Alpert alan.alpert at nokia.com
Mon Nov 21 03:59:06 CET 2011


On Sat, 19 Nov 2011 20:58:55 ext Mark Constable wrote:
> I'd like to use qmlviewer for some simple non-gui terminal tasks
> mainly to do with dumping both system and script state. This is the
> simplest console script I can come up with but I can't find any
> mechanism to disable that redundant (to me) first debug line...
> 
> import QtQuick 1.0
> Item {Component.onCompleted:{console.log("Hello World!");Qt.quit()}}
> 
> ~ qmlviewer hello-world-cli.qml
> Qml debugging is enabled. Only use this in a safe environment!

That is because the warning is printed by qmlviewer (and it means exactly what 
it says). If you want to run it as a console script, like python foo.py would, 
you'll need a different application. One which is not currently distributed 
with Qt, but would be easy enough to make (just a QDeclarativeEngine and 
instantiate a component per filename passed on the command line).

If you write your own application and do not explicitly turn on debugging then 
you will not get this error message.

> An associated suggestion is to provide perhaps a "console.print"
> function that sends to STDOUT and some of us may be able to
> squeeze some console goodness out of QML and the standard qmlviewer.

For some console goodness you'll probably want A) A non-graphical launcher 
(unlike qmlviewer) and B) An additional module with stdout/stdin support. 
Writing such objects and exposing them to QML shouldn't be that hard. But it's 
certainly not a use-case for the standard qmlviewer (a graphical debugging 
tool) or the QtQuick module (a module of GUI primitives).

-- 
Alan Alpert
Senior Engineer
Nokia, Qt Development Frameworks


More information about the Qt-qml mailing list