Last time out, I showed how to get
bi-directional communication going between Javascript and C++, using Qt's
Webkit component.
This time I'm going to stick with Qt but use its new shiny: Qt Quick. Qt Quick adds a markup language, QML, to the mix.
You use QML to declare which components to build your user interface from.
The idea is that a declarative specification will make your user interface work across different types of device (mobile is the main focus).
For application logic, you can use Javascript in QML. Alternatively you can
use a language which has Qt (and Qt Quick) bindings. Last time I used C++. This time I'll use
PySide — the Python bindings to Qt.
In my previous post, I showed how to
get bi-directional communication going between Javascript and Vala, using
GTK+'s Webkit component.
This time I'm going to do the same between Javascript and C++, using
Qt's Webkit component. Last time out I decided against
using C++ with GTK+ but Qt seems better suited to the language. Let's see
how Qt/C++ compares to GTK+/Vala.
We'll be sticking to the same example we used before with Vala:
I wanted to write a user interface in HTML and Javascript but run the rest of
the application in some other language that has access to system facilities.
Therefore I needed
bi-directional communication between the user interface and the application
logic. I also wanted to run it as a normal standalone application.
GTK+ and Qt both let you embed
the Webkit browser engine to do this. Another option
is to run Chromium in kiosk mode.
This post is about using GTK+'s Webkit component. Future posts will look at
Qt and Chromium.
I wanted a large on-screen volume indicator showing:
The microphone amplification level, changing as you adjust it (by pressing
keys, for example).
Whether the microphone is muted.
The current microphone level, changing as you speak into the microphone.
Here's what I did.