3 ms·
This is great news. Qt is really missing a scripting language story. Having python bindings as a first class citizen might bring a competitor to Electron, node-
by educar 10y ago
This is great news. Qt is really missing a scripting language story. Having python bindings as a first class citizen might bring a competitor to Electron, node-webkit etc (Qt has a chromium port).
Python is good, but I would love to see javascript bindings instead. Such a thing would make worthwhile node competitor.
- jdboyd 10y agoQt5 has JavaScript all over the place. JavaScript is the language used for the QML declarative GUI system, which is encouraged as the graphical basis for new Qt applications. That is based on QScriptEngine (based on V8) which is also usable separately from non-QML applications. QObjects that have been registered via QMetaType can be easily instantiated from inside JavaScript. On those QObjects, methods that have been declared as slots can be called painlessly from JavaScript. For a property to be accessible from JavaScript, it does have to be setup with Q_PROPERTY instead of just being a member variable, which is a bit more work on the C++ side, but once that is done it too is fairly seamless to the JavaScript engine. Also, there is Chromium as QWebEngine, since you mention it. Its JavaScript is less seamless with Qt since the two sides have to communicate via websockets. Previously there was QWebView which was more nicely integrated in with the rest of Qt, but I guess WebKit and Chromium both progressed in ways that were incompatible with that, thus its replacement. If you want to write a Qt application in JavaScript without writing a single bit of C++ you can do that with QML. If you want to write a traditional QWidget application in JavaScript then you will need to write a certain amount of bootstrap code. I would imagine there is room for improvement here, but it certainly isn't fair to suggest that there aren't JavaScript bindings or that they aren't officially supported as part of the project. Since you mention a node competitor, it would be interesting to try to use the Qt network server parts of the library to write a server in JavaScript. Perhaps it would inform me of areas where Qt's bindings for JavaScript are weak.
- educar 10y ago> If you want to write a Qt application in JavaScript without writing a single bit of C++ you can do that with QML Not really. You cannot write full blown business logic in javascript, you almost always end up in C++.Even simple things like accessing the file system or networking or process management are not available in QML. One has to write bindings for it from scratch. This is what I was referring to in my original comment. If we have proper bindings (like the PySide integration), then we will get all these APIs.