Incoming coordinates, simulate mouse click on a point on the page in 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);
Get the coordinates of the mouse click:
voidMainWindow:: Mousepressevent(qmouseevent*e) {int M_i_clickx=E -X (); int M_i_clicky=E -Y (); Qdebug ()<<M_i_clickx<<M_i_clicky;}voidMainWindow:: 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) { }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Simulate mouse click events in QT