Results 1 to 5 of 5

Thread: problem with keypress event and QTableView

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Question problem with keypress event and QTableView

    Hi,

    I have implemented the keypress event for QTableView and it is working file with enter key. i have reused the eventFilter() function of the QObject.

    Qt Code:
    1. void ClassXyz::eventFilter(QObject *recv, QEvent *event)
    2. {
    3. if(recv=tableview)
    4. {
    5. if(event->type() == QEvent::KeyPress)
    6. {
    7. QKeyEvent *ke = static_cast<QKeyEvent*>(event);
    8. if(ke->type() == Qt::Key_Tab)
    9. {
    10. //my own operation, move to next cell
    11. }
    12. }
    13. }
    14. else
    15. {
    16. //call QObject's eventFilter
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    the above code, says that if i press a tab key in a table view cell's "my own operation-cursor willl move next" has to be executed.

    Case 1:
    The problem is the eventFilter is not always called if i press the tab key when the cursor is in the cell (cell is in edit mode). i.e i have entered a data in a cell and if i press the tab key, no eventFilter is called and the cursor is not moving to next cell. Instead datachanged signal of the tableview is triggered.

    Case 2:
    But i have selected the cell (just a single click) and press tab key then the eventFilter function is called and the cursor is moving to next cell with display role.

    please tell me what will be problem. it is required for me to resolve the case1.

    Thanks
    ranna
    Last edited by wysota; 21st March 2009 at 00:35. Reason: missing [code] tags

  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: problem with keypress event and QTableView

    What did you install the event filter on?
    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 2008
    Posts
    4
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with keypress event and QTableView

    I have a similar problem. in my case I am using a delegate with a QTablewidget and a keypress event filter. I've been meaning to create a test case.

    Ranna, I assume you are running this on 4.5. Can you test it on 4.4.3? if its short, do you want me to try it?

    I had not problem with 4.4.3, but I have the problem with 4.5.0

  4. #4
    Join Date
    Sep 2008
    Posts
    17
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with keypress event and QTableView

    I am using only Qt 4.4

  5. #5
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with keypress event and QTableView

    Hi I'm using QT 4.5 and am trying to implement an eventFilter for my custom delegate.

    In short i Have a delegate subclassed from QItemDelegate using a QTextEdit (because i needed Highlighter functionality) and i want the Editor to be singlelined, so it should close whenever i press return.

    Does anyone have a tip for me? I am not quite sure how the eventfilter works. And all i got from the documentation is that this filter is used for such a task, but not how.

    Thanks

    Eric

Similar Threads

  1. QTableView doubleclicked event not working
    By sgmurphy19 in forum Qt Programming
    Replies: 6
    Last Post: 15th March 2009, 10:00
  2. Catch a row selection event in QTableView
    By Windsoarer in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2009, 22:44
  3. Problem with KeyPress event and QTableView
    By ranna in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 20:01

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.