Qt bindings for Node.js
We try to follow Qt's API as closely as possible, but sometimes quirks are inevitable (for example, virtual methods that handle events are translated into callback setters). See the header files in
src/ for a list of available bindings, and comments in
.cc files for possible API differences.
Supported platforms: Mac OS X | Windows | Linux
var qt = require'node-qt'app =window = ;// Prevent objects from being GC'dglobalapp = app;globalwindow = window;// Quirk: the virtual method paintEvent() is mapped into a callback setterwindowpaintEventvar p = ;pbeginwindow;pdrawText20 30 'hello node, hello qt';pend;;windowresize300 150;windowshow;// Join Node's event loopsetIntervalappprocessEvents 0;
From your project directory, run (see below for requirements):
$ npm install node-qt
This will download and build the latest release of Node-Qt in
node_modules/. Then create a new file, say
helloworld.js, copy the example above and run Node as usual:
$ node helloworld
See the examples/ directory for other simple use cases.
Node-Qt was designed to build seamlessly on a standard development box. The necessary platform-dependent Qt binaries are bundled with the module (due to heterogeneous dependencies, Linux is an exception).
$ sudo apt-get install pkg-config qt-sdk.
Node-Qt has been tested with Node 0.6.x.
To download and build the development version:
$ git clone git://github.com/arturadib/node-qt.git$ cd node-qt$ npm install
To run the unit tests:
$ node make test
(Ignore the image regression errors - they are based on snapshots that are platform- and backend-dependent).
Please provide a test case for every new binding added. See
test/ for examples of unit tests.
qclass.cc) from the provided templates
qclass.*: search and replace all occurrences of
__template__with the corresponding class name
node-qt.gyp: Add qclass.cc to sources list
qclass.h: Declare static method as per
qclass.cc: Implement method as per
Initialize(). Again see template.cc.
This is a list of common errors when experimenting with Node addons, and their possible solutions:
"Out of memory"
NODE_MODULE(name, ...) does not match target name?
"Unable to load shared library"
(v8 object)->Set() called to register a method, but method implementation
Tough luck :) Did you forget to
new a wrapped object?