-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.cpp
More file actions
54 lines (49 loc) · 1.14 KB
/
command.cpp
File metadata and controls
54 lines (49 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "command.h"
#include "iostream"
#include <QApplication>
#include <QMouseEvent>
#include <QPoint>
#include <QtGlobal>
#include <QTime>
#include <QThread>
using namespace std;
Command::Command()
{
}
void Command::Task(QWidget* widget)
{
int i = 0;
while(true)
{
QWidget widget1;
//cout << "hello kugou" << i << endl;
i++;
if(i>100)
{
break;
}
QThread::sleep(1);
}
}
void Command::test0(QWidget *widget)
{
QPoint pos;
int x = qrand() % 800;
int y = qrand() % 600;
cout << "x:" << x << " y:" << y << endl;
pos.setX(x);
pos.setY(y);
QMouseEvent *mEvnPress;
QMouseEvent *mEvnRelease;
try
{
mEvnPress = new QMouseEvent(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(widget->focusWidget(),mEvnPress);
mEvnRelease = new QMouseEvent(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
QApplication::sendEvent(widget->focusWidget(),mEvnRelease);
}
catch(exception& e)
{
cout << e.what() << endl;
}
}