synthetic mouse events in Qt 5.3 QGuiApplication
-
Hi All,
I've wtitten a Qt 5.3 QGuiApplication program which uses QtQuick and
pyotherside for the back end. I'm trying to control the program remotely
through a web browser.I send a screenshot out to the browser and get XY coordinates back, This
is working for the first button press. It doesn't work after that unless
I click on the actual display or move the mouse out of the window and back in.I've noticed that my program works when mouseGrabber == 0. After the
first click, this gets set and my program no longer works.It appears that I have to do some more event handling somewhere, but
after a few days of poring over documentation ( much of it appearing to
be useful but applying to QWidgets or Wt4 ) and trying
everything I can think of I've decided to ask for help.This is my first try at writing C++ for Qt and my second C++ program,
the first of which I wrote some 30 years ago,Here's a code snippet to show what I'm trying to do.
If someone could point me in the right direction, I would appreciate it.
Thanks.
void Wremote::mClick(int x, int y ) { QWindowList wl = QGuiApplication::allWindows(); _mwindow = wl[0]; QPointF pos((qreal)x,(qreal(y))); QMouseEvent pevent(QEvent::MouseButtonPress, pos, Qt::LeftButton ,Qt::LeftButton, 0); QMouseEvent revent(QEvent::MouseButtonRelease, pos, Qt::LeftButton ,Qt::LeftButton, 0); QGuiApplication::sendEvent(_mwindow, &pevent); QGuiApplication::sendEvent(_mwindow, &revent); QGuiApplication::processEvents(); }