-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
52 lines (38 loc) · 1.22 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
#include <string>
#include <QVBoxLayout>
#include <QSlider>
#include <QLabel>
#include "mainwindow.h"
#include "area_progress_bar.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
AreaProgressBar * progressBar = new AreaProgressBar();
setCentralWidget(progressBar);
QWidget * mainWidget = new QWidget(this);
QSlider * slider = new QSlider();
slider->setRange(0, 100);
slider->setSingleStep(1);
slider->setValue(0);
slider->setOrientation(Qt::Horizontal);
_valueLabel = new QLabel("0");
QHBoxLayout * hbox = new QHBoxLayout;
hbox->addWidget(slider);
hbox->addWidget(_valueLabel);
QVBoxLayout * vbox = new QVBoxLayout;
vbox->addWidget(progressBar);
vbox->addLayout(hbox);
mainWidget->setLayout(vbox);
setCentralWidget(mainWidget);
connect(slider, SIGNAL(valueChanged(int)), progressBar, SLOT(setValue(int)));
// On the slider value changes I want the text in the label to show the value.
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
}
MainWindow::~MainWindow()
{
}
void MainWindow::valueChanged(int value)
{
std::string s = std::to_string(value);
_valueLabel->setText(QString::fromStdString(s));
}