Qt5 C++ automated mouse clicking

僤鯓⒐⒋嵵緔 提交于 2019-12-05 10:30:56

I know that this is a bit late, but there are ways to do what you want. In general creating or simulating user interface events is used only for automated testing.

If you want the results of some calculation or algorithm there is almost always a better to get it desired result from a piece of software other than automating its UI. You can see if it has a documented API, you can call the same web services it calls, you can link against the same libraries it does or you can duplicate algorithms it uses.

If none of these are acceptable then you should probably look at the QT5 tutorials on automated testing.

Specifically the QTest Namespace. There are two overloads for functions that click the mouse called QTEST::mouseClick.

I think this might do what you want:

#include <QTest>

// class and function declarations removed here

QTest::mouseClick(d, Qt::LeftButton, Qt::NoModifier, QPoint(x,y));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!