Hi Ville, 2010/12/7 Ville M. Vainio <vivai...@gmail.com>: > Usually, callbacks in javascript are handled with anonymous functions > like here (from node.js): > > var net = require('net'); > net.createServer(function (socket) { > socket.write("Echo server\r\n"); > socket.on("data", function (data) { > socket.write(data); > }); > }).listen(8124, "127.0.0.1"); > > If socket was a QObject in c++ side, I would need to pass a function > to socket.on, store it somewhere and call it from C++ (most probaby > upon receiving a signal). How would I do it?
I think you should be able to use a Qt signal of the QObject (or add a new one) and then follow the instructions at this page (untested for anonymous functions, though) to hook it up to the function: http://doc.qt.nokia.com/4.7/scripting.html#reacting-to-c-objects-signals-in-scripts HTH. Thomas _______________________________________________ Qt-qml mailing list Qt-qml@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-qml