You have several ways to simulate mouse events in a Qt application. First, you can create and post mouse events using native functions like:
QMouseEvent eve(...); qApp->sendEvent(this , &eve);
Second, in QWebView, you can emulate the mouse action using javascript.
Third, you can use QTest lib for mouse emulation. The official tutorial is good. But you should include the correct include headers:
#include <QtTest/QtTest> #include <qtest_widgets.h>
Just include <QtTest/QtTest> is not enough, you may get the following errors:
error: ‘mouseClick’ is not a member of ‘QTest’
error: ‘keyClicks’ is not a member of ‘QTest’
Note that QTest is a namespace, not a class.
The include directories should have …mingw482_32\include\QtTest, and also you should add “-lQt5Test” to your compiling command.
Comments are closed, but trackbacks and pingbacks are open.