map one key to another (e.g. Return to Enter)
Unsolved
General and Desktop
-
Hello,
is it in general possible to globally map the return key to the enter key for the whole application, or at least some widget.
I have a itemview with some custom delegates and I can finish the editing by pressing the enter key, however the return key does not work.EDIT:
I'm kind of confused, when I try to catch the event and then forward it i can catch for example the Qt::Key_Escape but not the Qt::Key_Return. Where is the differnce??
bool MainWindow::eventFilter(QObject *target, QEvent *event) { // shortcut keys if(event->type() == QEvent::KeyPress) { QKeyEvent * keyEvent = dynamic_cast<QKeyEvent*>(event); if(keyEvent->key() == Qt::Key_Escape) { std::cout << "Escape" << std::endl; } if(keyEvent->key() == Qt::Key_Enter) { std::cout << "Enter" << std::endl; } } return false;
}
EDIT: I guess the problem is, that the Qt::Key_Enter event is processed by some button in the GUI that gets clicked when the Enter key is pressed. I have disabled the focus for the button, but it does not help.