Hi wysota!
Thanks for your reply. Unfortunately, I am unable to turn your suggestion into working code. I tried:
bool MyQPlaintTextEditor
::eventFilter(QObject* obj,
QEvent* event
) { if (event
->type
() == QEvent::KeyPress) { QKeyEvent* keyEvent
= static_cast<QKeyEvent
*>
(event
);
if ((keyEvent->modifiers() == 0) && (keyEvent->text() != "0") && (keyEvent->text() != "1")) {
return true;
}
}
// standard event processing
return QObject::eventFilter(obj, event
);
}
bool MyQPlaintTextEditor::eventFilter(QObject* obj, QEvent* event) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
if ((keyEvent->modifiers() == 0) && (keyEvent->text() != "0") && (keyEvent->text() != "1")) {
return true;
}
}
// standard event processing
return QObject::eventFilter(obj, event);
}
To copy to clipboard, switch view to plain text mode
I still can e.g. press AltGr-0 and get a "}" -> AltGr doesn't seem to be catched by modifiers(). Besides that, the code above doesn't allow me to navigate with cursor keys or use backspace. Do I really have to check all those keycodes and let them though? This seems odd to me. But as I said already: I think that playing with the key codes it too low level for my purpose...
Any other ideas? Thanks a lot!
Regards,
Paul
Bookmarks