I am using QWebEngineView to make a web view to my project so first I add a widget in the UI form and promoted it to QWebEngineView it works fine now I want to make a button press inside this widget on a point x,y (which is a button inside the website viewed in the widget) so I make a keypress when I press on S from the keyboard it save the point of the mouse hover inside this widget (I hover exactly on the button inside the website) I use this code to save the points
bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
if(keyEvent->key() == Qt::Key_S) {
p = ui->widget->mapFromGlobal(QCursor::pos()); //QPoint varible I use it to save the x,y inside the widget
qDebug() << "point inside the widget = " << p.x() << " " << p.y();
}
}
return QObject::eventFilter(watched, event);
}
then I have button when i press it should make a button press inside the QWebEngineView widget I use this code inside my button
QTest::mouseClick(ui->widget, Qt::LeftButton, Qt::KeyboardModifier::NoModifier, p);
//p saved the location of the button in the webview widget but it didn't press that button or make this button press ? so what is the problem of my code which make it not press on the button inside the webview or I should not use QTest for this?