0

I have a QWebView that loads a certain website. Now, I want to emulate a person that is typing something in a html input field.

I set the focus on the input field and then go:

QKeyEvent *event = new QKeyEvent(QEvent::KeyPress,Qt::Key_I,Qt::NoModifier);
QCoreApplication::postEvent(ui->webView, event);

This works, but the key entered is always an uppercase I. I need to send a lowercase i to the widget. Unfortunately the Qt class only offers Qt::Key_X or Qt::Key_A - not Qt::Key_a.

How can I solve this problem?

AudioGuy
  • 413
  • 5
  • 18
  • 2
    Have you tried setting the `text` parameter to the [`QKeyEvent` constructor](http://doc.qt.io/qt-5/qkeyevent.html#QKeyEvent) to the appropriate string? – G.M. Jun 17 '17 at 10:22
  • 1
    Thank you, that did it. Strange how you need to send a QKey AND optionally a QString... I would have expected a different method overload... ;-) – AudioGuy Jun 18 '17 at 11:13

0 Answers0