Hi,

Is there any issues with making the slot keyPressEvent() public?

I have a QWidget (called say A) that has a button on it which opens a QWidget window (called B) which gains the focus and I want certain keys entered on the keyboard to be ignored by 'B' and passed through to 'A' to be able to use. The only way I can get this to work is the move the header definition of keyPressEvent() from protected to public... is this a bad thing to do or is there a better way around it...

Qt Code:
  1. void B::keyPressEvent(QKeyEvent *k)
  2. {
  3. if((B->hasFocus()) && !(k->key() >= Qt::Key_F1 && k->key() <= Qt::Key_F20))
  4. {
  5. QApplication::sendEvent(B->focusWidget(), k);
  6. }
  7. else
  8. {
  9. A->keyPressEvent(k); //This doesn't work if it is protected slot in A.h needs to be public slot
  10. }
  11. }
To copy to clipboard, switch view to plain text mode 

Thank you for any help.