-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
82 lines (68 loc) · 2.9 KB
/
mainwindow.cpp
File metadata and controls
82 lines (68 loc) · 2.9 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
// QPushButton {color : red}
ui->lineEdit->setStyleSheet("background-color: black; color: white");
ui->label->setStyleSheet("background-color: black; color: white");
ui->label_2->setStyleSheet("background-color: black; color: white");
ui->lcdNumber->setStyleSheet("background-color: black; color: white");
ui->lcdNumber_2->setStyleSheet("background-color: black; color: white");
ui->centralwidget->setStyleSheet("background-color: black; color: white");
ui->pushButton->setStyleSheet("border: 1px solid red");
ui->menubar->setStyleSheet("background-color: black; color: white");
ui->statusbar->setStyleSheet("background-color: black; color: white");
ui->pushButton_2->setStyleSheet("border: 1px solid red");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
static int heads = 1;
static int tails = 1;
srand(time(0));
if (rand() % 2 == 0)
{
ui->lineEdit->setText("Heads");
ui->lcdNumber->display(heads);
heads++;
}
else if (rand() % 2 != 0)
{
ui->lineEdit->setText("Tails");
ui->lcdNumber_2->display(tails);
tails++;
}
}
void MainWindow::on_pushButton_2_clicked()
{
QString mode=ui->pushButton_2->text();
if(mode=="Light Mode"){
ui->lineEdit->setStyleSheet("background-color: white; color: black");
ui->label->setStyleSheet("background-color: white; color: black");
ui->label_2->setStyleSheet("background-color: white; color: black");
ui->lcdNumber->setStyleSheet("background-color: white; color: black");
ui->lcdNumber_2->setStyleSheet("background-color: white; color: black");
ui->centralwidget->setStyleSheet("background-color: white; color: black");
ui->pushButton->setStyleSheet("border: 1px solid red");
ui->menubar->setStyleSheet("background-color: white; color: black");
ui->statusbar->setStyleSheet("background-color: white; color: black");
ui->pushButton_2->setText("Dark Mode");
}
else if(mode=="Dark Mode"){
ui->lineEdit->setStyleSheet("background-color: black; color: white");
ui->label->setStyleSheet("background-color: black; color: white");
ui->label_2->setStyleSheet("background-color: black; color: white");
ui->lcdNumber->setStyleSheet("background-color: black; color: white");
ui->lcdNumber_2->setStyleSheet("background-color: black; color: white");
ui->centralwidget->setStyleSheet("background-color: black; color: white");
ui->pushButton->setStyleSheet("border: 1px solid red");
ui->menubar->setStyleSheet("background-color: black; color: white");
ui->statusbar->setStyleSheet("background-color: black; color: white");
ui->pushButton_2->setText("Light Mode");
}
}