Results 1 to 5 of 5

Thread: problem with keypress event and QTableView

Threaded View

Previous Post Previous Post   Next Post Next Post
  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

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
  •  
Qt is a trademark of The Qt Company.