-
Notifications
You must be signed in to change notification settings - Fork 13
/
mainwindow.cpp
60 lines (43 loc) · 1.52 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
createConnection();
}
MainWindow::~MainWindow()
{
}
void MainWindow::createConnection()
{
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(onActionAboutClicked() ));
connect(ui->widget, SIGNAL(sgConnected(QString)), this, SLOT(onConnected(QString) ));
connect(ui->widget, SIGNAL(sgDisconnected(QString)), this, SLOT(onDisconnected(QString) ));
setStyleSheet(" QMainWindow {"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ff0000, stop: 1 #ffff00); "
"}" );
}
void MainWindow::onActionAboutClicked()
{
QMessageBox::about(this, "Made by", "CharlesPark");
}
void MainWindow::closeEvent(QCloseEvent * event)
{
ui->widget->closeEvent(event);
}
void MainWindow::onConnected(QString str)
{
setStyleSheet(" QMainWindow {"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #007f00, stop: 1 #aaffaa); "
"}" );
ui->statusBar->showMessage(str);
}
void MainWindow::onDisconnected(QString str)
{
setStyleSheet(" QMainWindow {"
" background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ff0000, stop: 1 #ffff00); "
"}" );
ui->statusBar->showMessage(str);
}