-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.cpp
61 lines (56 loc) · 1.87 KB
/
MainWindow.cpp
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
55
56
57
58
59
60
61
#include <QKeyEvent>
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "ShuttleHelper.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_page(nullptr)
{
ui->setupUi(this);
m_page = new Page();
connect(ui->btn1, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn2, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn3, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn4, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn5, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn6, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn7, &MyPushButton::clicked, m_page, &Page::show);
connect(ui->btn8, &MyPushButton::clicked, m_page, &Page::show);
QVector<QWidget*> vec;
vec << ui->btn1 << ui->btn2 << ui->btn3 << ui->btn4
<< ui->btn5 << ui->btn6 << ui->btn7 << ui->btn8
<< ui->horizontalScrollBar;
ShuttleHelper::Instance().UpdateMainWindow(vec, ui->btn1);
}
MainWindow::~MainWindow()
{
delete ui;
if(nullptr != m_page)
{
delete m_page;
}
}
bool MainWindow::event(QEvent *e)
{
if(QEvent::MouseButtonPress == e->type())
{
ShuttleHelper::Instance().SetClickFlag();
} // 以下模拟编码器操作
else if(QEvent::KeyPress == e->type() && Qt::Key_A == dynamic_cast<QKeyEvent*>(e)->key())
{
ShuttleHelper::Instance().onLeft();
}
else if(QEvent::KeyPress == e->type() && Qt::Key_D == dynamic_cast<QKeyEvent*>(e)->key())
{
ShuttleHelper::Instance().onRight();
}
else if(QEvent::KeyPress == e->type() &&
(Qt::Key_Enter == dynamic_cast<QKeyEvent*>(e)->key() || Qt::Key_Return == dynamic_cast<QKeyEvent*>(e)->key()))
{
ShuttleHelper::Instance().onEnter();
}
else
{}
return QWidget::event(e);
}