PDA

View Full Version : Binding keyPressEvent() to a QTableWidget with QT Script



De_Dood
15th June 2010, 12:36
Hi all,

Can anyone tell me how I can bind the keyPressEvent() (ore something similar) to a QTableWidget so that I check which key was pressed in a cell?

I tried somthing like this:


...
twTable.keyPressEvent = function(e) {
//Do something
}
...


But it didn't work.

Thanks

wysota
15th June 2010, 23:30
This won't work because keyPressEvent is not a slot so it is not visible from within QtScript. Make a custom function (or even class) that will install an event filter on the widget.

De_Dood
16th June 2010, 08:19
Thank you for the answer wysota,

But is it possible to show me an examlpe on how to do that? Or is there somewhere some documentation about this?
I also like to note that I can only use QT Script for this project, so I can't start changing the code of the application that runs the script.

Thanks in advance.

wysota
16th June 2010, 11:32
I also like to note that I can only use QT Script for this project, so I can't start changing the code of the application that runs the script.
This can't be done without extending your scripting environment.