Results 1 to 6 of 6

Thread: keyPressevent not working with timer.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Nov 2010
    Posts
    20
    Thanks
    2
    Qt products
    Qt4

    Default Re: keyPressevent not working with timer.

    Doesn't work with escape being pressed. If I set keyval = 111 in the keyPressEvent call and comment out the conditional operator, it should set keyval to 111 with any keypress. But its not. Likewise, if I set keyval=111 in the mousePressEvent below, it works, and is being called. Why isn't keyPressEvent being called?

    Thanks in advance.

    Qt Code:
    1. void GLWidget::keyPressEvent(QKeyEvent *e)
    2. {
    3. /*
    4. switch( e->key() )
    5. {
    6. case Qt::Key_Escape:
    7. keyval=111;
    8. }
    9. */
    10.  
    11. keyval = 111; // the label should read 111 if any keypress is occuring
    12.  
    13. }
    14.  
    15. void GLWidget::mousePressEvent(QMouseEvent *event)
    16. {
    17. lastPos = event->pos();
    18. // if I put keyval = 111 here, it shows in the label with mousepress
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by T1001; 8th December 2010 at 15:51. Reason: code tages
    All Your Base Are Belong To Us

Similar Threads

  1. killing Qt timer.
    By jaxrpc in forum Newbie
    Replies: 5
    Last Post: 1st June 2010, 00:21
  2. vertical keypressevent not working on graphicsitem
    By creatio.x in forum Qt Programming
    Replies: 3
    Last Post: 25th December 2009, 11:23
  3. implemet a timer
    By adamatic in forum Qt Programming
    Replies: 12
    Last Post: 17th February 2009, 07:31
  4. Timer for application
    By Zergi in forum Qt Programming
    Replies: 3
    Last Post: 26th December 2007, 22:21
  5. Timer call
    By mahe2310 in forum Qt Programming
    Replies: 1
    Last Post: 28th March 2006, 08:57

Tags for this Thread

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.