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...
{
if((B->hasFocus()) && !(k->key() >= Qt::Key_F1 && k->key() <= Qt::Key_F20))
{
}
else
{
A->keyPressEvent(k); //This doesn't work if it is protected slot in A.h needs to be public slot
}
}
void B::keyPressEvent(QKeyEvent *k)
{
if((B->hasFocus()) && !(k->key() >= Qt::Key_F1 && k->key() <= Qt::Key_F20))
{
QApplication::sendEvent(B->focusWidget(), k);
}
else
{
A->keyPressEvent(k); //This doesn't work if it is protected slot in A.h needs to be public slot
}
}
To copy to clipboard, switch view to plain text mode
Thank you for any help.
Bookmarks