Results 1 to 4 of 4

Thread: Binding keyPressEvent() to a QTableWidget with QT Script

  1. #1
    Join Date
    Jun 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Binding keyPressEvent() to a QTableWidget with QT Script

    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:
    Qt Code:
    1. ...
    2. twTable.keyPressEvent = function(e) {
    3. //Do something
    4. }
    5. ...
    To copy to clipboard, switch view to plain text mode 

    But it didn't work.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Binding keyPressEvent() to a QTableWidget with QT Script

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Binding keyPressEvent() to a QTableWidget with QT Script

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Binding keyPressEvent() to a QTableWidget with QT Script

    Quote Originally Posted by De_Dood View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 8
    Last Post: 16th October 2009, 14:44
  2. Binding data to a a QGraphicsItem (or something like that)
    By been_1990 in forum Qt Programming
    Replies: 18
    Last Post: 13th August 2009, 08:33
  3. Can I include a script from script?
    By yycking in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 03:01
  4. QUdpSocket binding
    By db in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2008, 11:24
  5. binding
    By mickey in forum General Discussion
    Replies: 9
    Last Post: 26th September 2006, 21:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.