I have created a subclass of QComboBox where I want to catch keys from 'a' to 'z' and manually force them to capital letters 'A'-'Z'. It has to be done real-time like caps lock was pressed.

I'm trying the following approach w/o success:

Qt Code:
  1. void CommandBox::keyPressEvent(QKeyEvent *e) {
  2. if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) {
  3. emit enterPressed(currentText());
  4. } else if (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z) {
  5. if (capital) e->setModifiers(Qt::ShiftModifier);
  6. }
  7. qDebug() << e->key() << e->modifiers();
  8. QComboBox::keyPressEvent(e);
  9. }
To copy to clipboard, switch view to plain text mode 

The modifier is set, I can see it in the printout of qDebug(), but the character is still lower case in the field.
Any guess?

Thanks!