QKeyPress - Simulating key press
https://www.qtcentre.org/threads/153...keyboard-press
I tried the same approach, but not able to get written on the lineEdit widget
Code:
ui->lineEdit->setFocus();
Alternately
also didn't succeed.
I tried the below also and didn't get any result.
Code:
if (key.isAccepted()) {
qDebug()<<"everything is ok";
} else {
qDebug()<<"something wrong";
}
Please suggest what am I missing.
Regards,
Sayan
Re: QKeyPress - Simulating key press
Hi,
got it done.
Quote:
ui->lineEdit->setFocus();
QKeyEvent *key_press = new QKeyEvent(QKeyEvent::KeyPress, Qt::Key_X, Qt::NoModifier, "x");
QApplication::sendEvent(ui->lineEdit, key_press);
the last parameter ..