PDA

View Full Version : keyPressEvent(QKeyEvent* event) is introducing some bugs



metRo_
3rd October 2010, 15:42
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!
}

tbscope
3rd October 2010, 18:43
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?

squidge
3rd October 2010, 19:28
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.

chris_helloworld
4th October 2010, 15:39
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,



void MyClass::keyPressEvent(QKeyEvent *event)
{
if (processKeyEvents == true) {
SuperClass::keyPressEvent(event);
} else {
event.accept();
}
}