qtwebengine - Qt WebEngine simulate Mouse Event -


i want simulate mouse event in qt webengine app.

i use pyqt5.8 , qt5.8.

this code:

    def mouse_click(self, x, y):         point = qpoint(int(x),                     int(y))         eventp = qmouseevent(qmouseevent.mousebuttonpress,point,qt.leftbutton,qt.leftbutton,qt.nomodifier)         self.sendevent(eventp)         eventp = qmouseevent(qmouseevent.mousebuttonrelease,point,qt.leftbutton,qt.leftbutton,qt.nomodifier)         self.sendevent(eventp)        def sendevent(self, event):          recipient = self.webpage.view().focusproxy()          recipient.grabkeyboard()          self.application.sendevent(recipient, event)          recipient.releasekeyboard() 

i test it, not worked. can confirm mouse cursor on element, no mouse click event happend. can me?

i use mac os 10.12.4, test using demo, find can not catch mouse event, can catch other events. suggestions?

for qt 5.8 running following code:

void leftmouseclick(qwidget* eventsreciverwidget, qpoint clickpos) {     qmouseevent *press = new qmouseevent(qevent::mousebuttonpress,                                             clickpos,                                             qt::leftbutton,                                             qt::mousebutton::nobutton,                                             qt::nomodifier);     qcoreapplication::postevent(eventsreciverwidget, press);     // delay     qtimer::singleshot(300, [clickpos, eventsreciverwidget]() {         qmouseevent *release = new qmouseevent(qevent::mousebuttonrelease,                                                 clickpos,                                                 qt::leftbutton,                                                 qt::mousebutton::nobutton,                                                 qt::nomodifier);         qcoreapplication::postevent(eventsreciverwidget, release);     })); } qwebengineview webview = new qwebengineview(); // need find first child widget of qwebengineview. can accept user input events. qwidget* eventsreciverwidget = nullptr; foreach(qobject* obj, webview->children()) {     qwidget* wgt = qobject_cast<qwidget*>(obj);     if (wgt)     {         eventsreciverwidget = wgt;         break;     } } qpoint clickpos(100, 100); leftmouseclick(eventsreciverwidget, clickpos); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -