Results 1 to 4 of 4

Thread: keyPressEvent(QKeyEvent* event) is introducing some bugs

  1. #1
    Join Date
    Mar 2010
    Posts
    56
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default keyPressEvent(QKeyEvent* event) is introducing some bugs

    I have an aplication where i use KeyPressEvent and it is introducing some bugs in my aplication and i can't figure it out. What i want to try now is if it possible to stop a event from execute during an aplication.
    like:
    function teste(){
    //start
    KeyPressEvents = off!
    .....
    .....
    .....
    //finish
    KeyPressEvents = on!
    }

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: keyPressEvent(QKeyEvent* event) is introducing some bugs

    You can stop events from reaching the destination by installing an event filter and blocking the events in the filter

    However, before doing this, maybe it's a good idea to solve the bugs.
    Can you explain which bugs you have?

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: keyPressEvent(QKeyEvent* event) is introducing some bugs

    You do understand no events run until your program returns control to the applications message pump, right? So you will be only be blocking the events from being queued and typically, you want to know what you have missed since the last time you checked.

  4. #4
    Join Date
    Feb 2010
    Posts
    52
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Default Re: keyPressEvent(QKeyEvent* event) is introducing some bugs

    I think what you want to do is be able to control whether keyEvents are processed depending upon the state of some variable. So you might want to do something like,

    Qt Code:
    1. void MyClass::keyPressEvent(QKeyEvent *event)
    2. {
    3. if (processKeyEvents == true) {
    4. SuperClass::keyPressEvent(event);
    5. } else {
    6. event.accept();
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QLineEdit and keyPressEvent(QKeyEvent *)
    By fear in forum Qt Programming
    Replies: 6
    Last Post: 3rd June 2008, 20:31
  2. Introducing ChainLink: Matlab-style GUI for Qt4 developers
    By magland in forum Qt-based Software
    Replies: 9
    Last Post: 19th December 2007, 05:56
  3. Qt 4.3.0 lots of Bugs!
    By VireX in forum Qt Programming
    Replies: 69
    Last Post: 20th June 2007, 23:05
  4. QLineEdit & keyPressEvent(QKeyEvent *)
    By munna in forum Newbie
    Replies: 7
    Last Post: 29th March 2006, 15:50
  5. Bugs, style changes in 4.1.0?
    By simk in forum Qt Programming
    Replies: 13
    Last Post: 13th February 2006, 12:05

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.