bool t::eventfilter(qobject *obj, qevent *event) { if (event->type() == qevent::keypress) { qkeyevent *keyevent = static_cast<qkeyevent*>(event); if (keyevent->key()==qt::key_w)emit wevent(); if (keyevent->key()==qt::key_a)emit aevent(); if (keyevent->key()==qt::key_s)emit sevent(); if (keyevent->key()==qt::key_d)emit devent(); return true; } else { return qobject::eventfilter(obj, event); } }
if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { if (keyEvent->modifiers() & Qt::ControlModifier) { /*!this "if" statement is needed for opening edit dialog when control key is pressed.*/ return false; } focusNextChild(); return true; } }
if (keyEvent->modifiers() & Qt::ControlModifier)
void QWidget::grabKeyboard ()