I have created Web-browser using Active-qt in one widget and in the second widget I am having a virtual keyboard created by me. I have to write in the text box of browser(for example google search box) with virtual keyboard. I am using key-board send event method to send the key-press events to browser but it is not writing in the web-browser. When I have created a line edit in the first widget and trying to write via same virtual keyboard then it is writing perfectly but in case of browser it is not writing. So I wanted to access the HTML content of Browser to get the the id of search box of website. So I set the focus to that particular Id. I am helpless please help. Thanks in advance. Technology Stack QT:Active Qt component, Qt 5.7.0, Qt creator IDE with Min Gw and c++.
Edit: code snippet of test case send single button press event to webbrowser attaching designer snap as well as code snippet. enter image description here
UseKeyBoardDialog::UseKeyBoardDialog(QWidget *parent) : QDialog(parent)
{
setupUi(this);
WebBrowser->setControl("8856F961-340A-11D0-A96B-00C04FD705A2");
QString htmlDoc = WebBrowser->generateDocumentation();
QString outputFilename = "Results.html";
QFile outputFile(outputFilename);
outputFile.open(QIODevice::WriteOnly);
/* Check it opened OK */
if(!outputFile.isOpen()){
qDebug() << "- Error, unable to open" << outputFilename << "for output";
}
/* Point a QTextStream object at the file */
QTextStream outStream(&outputFile);
/* Write the line to the file */
outStream << htmlDoc;
/* Close the file */
outputFile.close();
//qDebug()<<"htmlDoc "<<htmlDoc;
}
void UseKeyBoardDialog::navigate(const QString &url)
{
WebBrowser->dynamicCall("Navigate(const QString&)", url);
}
void UseKeyBoardDialog::on_pushButton_clicked()
{
// lineEdit->setFocus();
WebBrowser->setFocus();
keybd_event( 0,
0x1E,
KEYEVENTF_SCANCODE| 0,
0 );
// Simulate a key release
keybd_event( 0,
0x1E,
KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE,
0);
}