[mythtv] How to send a key event from MythLineEdit?

zoiks2004-ivtv at yahoo.com zoiks2004-ivtv at yahoo.com
Sun Jun 19 05:46:48 UTC 2005


I'm trying to make a different key get processed
within the keyPressEvent() method of MythLineEdit.  

For example, say I wanted to replace a received
pressed key event with a QKeyEvent for pressing the
"a" key.  I try this snippet:

    [...]
    QKeyEvent key(QEvent::KeyPress, Qt::Key_A, 0,
Qt::NoButton);
    QLineEdit::keyPressEvent(&key);
    e->accept();  //e is the orig. key event, ignored
    handled = true;
    [...skips rest of keyPressEvent...]

or this one

    [...]
    QKeyEvent key(QEvent::KeyPress, Qt::Key_A, 0,
Qt::NoButton);
    QObject *key_target = gContext->GetMainWindow();
    QApplication::sendEvent(key_target, &key);
    e->accept();
    handled = true;
    [...skips rest of keyPressEvent...]

but neither works.  QLineEdit (MythLineEdit) never
sees the "a" keypress.  (Or the original keypress
event, I might add.)

What am I doing wrong?  It compiles, but the "a" key
event is never received.  Thanks.


More information about the mythtv-dev mailing list