-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdisplayText.cpp
47 lines (42 loc) · 1.21 KB
/
displayText.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
#pragma once
#include "stdafx.h"
#include "displayText.h"
displayText::displayText(int row, QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
this->setWindowTitle("Subtitle");
QSize size = qApp->screens()[0]->size();
QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(ui.widget->layout());
for (int i = 0; i < row; i++) {
QLabel* label = new QLabel(ui.widget);
label->setWordWrap(true);
label->setStyleSheet("background-color: rgba(0,0,0,0); color: white; font-size: 30px;");
layout->insertWidget(-1, label);
labelList.push_back(label);
}
}
displayText::~displayText()
{}
void displayText::updateLabel(int row)
{
if (row > labelList.size()) {
QVBoxLayout* layout = qobject_cast<QVBoxLayout*>(ui.widget->layout());
QLabel* label = new QLabel(ui.widget);
label->setWordWrap(true);
label->setStyleSheet("background-color: rgba(0,0,0,0); color: white; font-size: 30px;");
layout->insertWidget(-1, label);
labelList.push_back(label);
}
if (row < labelList.size()) {
delete labelList.back();
labelList.pop_back();
}
}
void displayText::setTranslation(QString string)
{
labelList.back()->setText(string);
}
void displayText::setRecognition(QString string) {
labelList.front()->setText(string);
}