[Qt-qml] How to spawn N8 Apps from within QML?

Niels Mayer nielsmayer at gmail.com
Tue Nov 9 20:01:16 CET 2010


I added a comment to the issue:
http://bugreports.qt.nokia.com/browse/QTBUG-15178?focusedCommentId=132078&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_132078
...................
Although "expect" is a tcl-based tool, there's also applications built
on "libexpect" which aren't TCL based. The example I gave in
http://lists.trolltech.com/pipermail/qt-qml/2010-November/001566.html
was for http://nielsmayer.com/winterp/ 's expect-based subprocess
facility. In that environment, expect based subprocesses get launched,
and callbacks for read or write activity on the file-descriptors are
setup "behind the scenes." This allows for easy integration of
subprocesses into event-driven UI frameworks – activity in the
subprocess just becomes another event. (In use for media
capture/conversion in a 1995-era web-based multimedia editor:
http://nielsmayer.com/wwweasel/node15.html
http://nielsmayer.com/wwweasel/node12.html )
Treating subprocesses in a similarly abstract way in QtQuick/QML could
allow them to be handled in a "declarative" fashion with code that
invokes http://doc.qt.nokia.com/4.7/qsocketnotifier.html "under the
hood."

I've attached the C code implementing the subprocess functionality.
There's some useful, oddball state-machine code in there that could be
used elsewhere, once you get past the Xt/Motif API usage, as well as
the XLISP API usage (the C code implements the lisp primitives).

For example, a demo application that runs the unix "bc" infinite
precision calculator, and keeps it busy computing sequential squares
of the previous number to the power two; the UI remains responsive
because the computations are all happening in the subprocess, and
returning back to the UI as events:

http://nielsmayer.com/winterp/scrnsnaps/inf-square.gif
http://nielsmayer.com/winterp/examples/inf-square.lsp
....................

Now that I've read the responses and more documentation, seems like a
good first approach would be to attempt to add "primitives" to QML
that are implemented in C, using technique described in
http://doc.trolltech.com/4.7-snapshot/qtbinding.html#calling-c-methods-from-qml
; http://doc.trolltech.com/4.7/qprocess.html handles subprocesses
already so it's just a small matter of programming from there.... :-)

Many of the C/C++ primitives needed  are discussed here in the links
below, but QML-equivalents are not readily found for all these
examples and http://doc.qt.nokia.com/qtmobility-1.1-tp/qdeclarativeexamples.html
404's....

http://doc.qt.nokia.com/qtmobility-1.1-tp/
http://doc.qt.nokia.com/qtmobility-1.1-tp/camera.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/contacts.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/gallery.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/feedback.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/location-overview.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/messaging.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/multimedia.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/organizer.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/publ-subs.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/service-frameworks.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/sensors-api.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/systeminfo.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/telephony.html
http://doc.qt.nokia.com/qtmobility-1.1-tp/versit.html

Some QML specific refs found in above docs:

http://doc.qt.nokia.com/qtmobility-1.1-tp/qml-soundeffect.html
QML SoundEffect Element

http://doc.qt.nokia.com/qtmobility-1.1-tp/qml-audio.html
QML Audio Element

http://doc.qt.nokia.com/qtmobility-1.1-tp/qml-video.html
QML Video Element

http://doc.qt.nokia.com/qtmobility-1.1-tp/battery-charge.html
Accessing Publish and Subscribe from QML

Niels
http://nielsmayer.com




More information about the Qt-qml mailing list