-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
56 lines (45 loc) · 1.41 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"
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) {
// No title bar, Stays on top always
setWindowFlags(Qt::Window | Qt::FramelessWindowHint |
Qt::WindowStaysOnTopHint);
// Maths for good location and size
height = QApplication::desktop()->screenGeometry().height();
width = QApplication::desktop()->screenGeometry().width();
resize(width*.28,height*.1);
move(width*.7, height*.1);
v = new QVBoxLayout;
t = new QTextEdit;
// Text Box formatting
t->setFrameStyle(QFrame::NoFrame);
t->setEnabled(false);
t->setFont(QFont("Arial", 16, 2));
stylesheet = "QWidget { background-color : rgb(34, 49, 63) } QTextEdit { background-color : rgb(34, 49, 63) } QTextEdit { color : rgb(25, 181, 254) }";
this->setStyleSheet(stylesheet);
this->hide();
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(process()));
timer->setSingleShot(false);
timer->setInterval(6000);
timer->start();
v->addWidget(t);
this->setLayout(v);
}
void MainWindow::recieveMsg(QString v) {
vec.push_back(v);
}
void MainWindow::process() {
if(!vec.empty()) {
QString tmp = vec.front();
t->setText(tmp);
vec.pop_front();
this->show();
QTimer::singleShot(5000, this, SLOT(hide()));
}
}
MainWindow::~MainWindow()
{
delete(t);
delete(l);
delete(v);
}