传入座标,模拟鼠标点击QWebView中网页上的某一点
qDebug()<<"mouse clicked";
QPoint pos(403,34);
QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(view->page(), &event0);
QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(view->page(), &event1);
获取鼠标点击的座标:
void MainWindow::mousePressEvent(QMouseEvent *e)
{
int m_i_clickX = e->x();
int m_i_clickY = e->y();
qDebug()<<m_i_clickX<<m_i_clickY;
}
void MainWindow::mouseReleaseEvent(QMouseEvent *e)
{
int m_i_clickX = e->x();
int m_i_clickY = e->y();
qDebug()<<"release"<<m_i_clickX<<m_i_clickY;
if(e->button()== Qt::LeftButton)
{
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-13 15:44:15