Я себе недавно вот такую плюху замутил:
C++ (Qt)
...............
keysMap_ [Qt::Key_2] = Qt::Key_Down;
keysMap_ [Qt::Key_4] = Qt::Key_Left;
keysMap_ [Qt::Key_6] = Qt::Key_Right;
keysMap_ [Qt::Key_8] = Qt::Key_Up;
keysMap_ [Qt::Key_5] = Qt::Key_Enter;
..............
void MainWindow::mapKeyEvent (const QKeyEvent* mappedEvent) const
{
const Qt::Key key = static_cast <Qt::Key> (mappedEvent->key ());
KeyMapIterator it (keysMap_);
while (it.hasNext ()) {
it.next ();
if (it.key () == key) {
QKeyEvent *ev = new QKeyEvent (mappedEvent->type (),
it.value (),
mappedEvent->modifiers (),
mappedEvent->text ());
QApplication::sendEvent (declarativeView, ev);
}
}
}
void MainWindow::keyPressEvent (QKeyEvent* e)
{
QMainWindow::keyPressEvent (e);
if (e->modifiers () == 0) {
mapKeyEvent (e);
}
}
Может пригодится.