Pay atention to compiler warnings, it should warn you that there is no return value in function returning bool:
if(e
->type
()==QEvent::KeyPress){ }
// and if not keyPress then ... ?
}
bool test1::eventFilter(QObject *o, QEvent *e){
if(e->type()==QEvent::KeyPress){
return QObject::eventFilter(o,e);
}
// and if not keyPress then ... ?
}
To copy to clipboard, switch view to plain text mode
Result returned by such function is undefined. Probably you are filtering out the paint events for these widgets.
To fix this, always return default base class eventFilter() when you don't want to filter the event out:
if(e
->type
()==QEvent::KeyPress){ // handle key press
return true; // filter out this event
}
return QDialog::eventFilter(o,e
);
// or whatever is the base class for test1 }
bool test1::eventFilter(QObject *o, QEvent *e){
if(e->type()==QEvent::KeyPress){
// handle key press
return true; // filter out this event
}
return QDialog::eventFilter(o,e); // or whatever is the base class for test1
}
To copy to clipboard, switch view to plain text mode
To avoid such errors in the future, add this flag to compiler flags:
-Werror=return-type
-Werror=return-type
To copy to clipboard, switch view to plain text mode
or better
-Wall -Werror
-Wall -Werror
To copy to clipboard, switch view to plain text mode
Bookmarks