Details
-
Task
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
None
Description
QtScript does not have any support for associating a script function with a C++ event. You have to do all the work yourself, e.g.
- subclass a widget in C++
- reimplement event()
- call the proper script function
This is quite a bit of work that you have to do just to be able to implement a simple key- or mouse-event handler in script.
It would be nice if QtScript provided some means of simplifying this. In an ideal world, you could simply do
widget.keyPressEvent = function(e) {
switch (e.key)
}
We had built-in support for event handlers in QtScript a while back, using event filters to do the magic. But it was removed because we weren't sure that it was the right way to do it... So this needs to be researched.
This is not just relevant for QObject-derived classes; the QtScript bindings for GraphicsView would be that much more powerful if you could easily set your own event handlers in scripts.