npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-qt

v0.0.2

Published

Qt bindings for Node.js

Downloads

104

Readme

Node-Qt

Node-Qt provides native bindings to the Qt library as a Node.js addon. The focus is on graphics and audio bindings; there is no need to duplicate the functionality of the Node API and its modules.

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

Hello world

var qt = require('node-qt'),
    app = new qt.QApplication,
    window = new qt.QWidget;

// Prevent objects from being GC'd
global.app = app;
global.window = window;

// Quirk: the virtual method paintEvent() is mapped into a callback setter
window.paintEvent(function() {
  var p = new qt.QPainter();
  p.begin(window);
  p.drawText(20, 30, 'hello node, hello qt');
  p.end();
});

window.resize(300, 150);
window.show();

// Join Node's event loop
setInterval(app.processEvents, 0);

Getting started

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.

Requirements

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).

  • Mac: Python, Make, and GCC.
  • Windows: Python and MSVC++ (either free or commercial).
  • Linux: Python, Make, GCC, and Qt 4.7+. To install Qt on Ubuntu: $ sudo apt-get install pkg-config qt-sdk.

Node-Qt has been tested with Node 0.6.x.

Contributing

Building and testing

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).

Creating new bindings

Please provide a test case for every new binding added. See test/ for examples of unit tests.

Binding to new classes

  1. Create your files (e.g. qclass.h, qclass.cc) from the provided templates src/template.h, src/template.cc
  2. qclass.*: search and replace all occurrences of __Template__, __TEMPLATE__, and __template__ with the corresponding class name
  3. node-qt.gyp: Add qclass.cc to sources list
  4. qt.cc: Include qclass.h
  5. qt.cc: Add QClass::Initialize() to Initialize()

Binding to new methods

  1. qclass.h: Declare static method as per Example() method in template.h
  2. qclass.cc: Implement method as per Example() in template.cc
  3. qclass.cc: Expose method to JavaScript via tpl->PrototypeTemplate() call in Initialize(). Again see template.cc.

Common errors

This is a list of common errors when experimenting with Node addons, and their possible solutions:

"Out of memory"

name in NODE_MODULE(name, ...) does not match target name?

"Unable to load shared library"

(v8 object)->Set() called to register a method, but method implementation is missing?

"Segmentation fault"

Tough luck :) Did you forget to new a wrapped object?