-
Notifications
You must be signed in to change notification settings - Fork 0
/
sliderdialog.cpp
37 lines (29 loc) · 864 Bytes
/
sliderdialog.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
#include "sliderdialog.h"
// SliderDialog.cpp
#include "sliderdialog.h"
#include <QLabel>
#include <QVBoxLayout>
SliderDialog::SliderDialog(QWidget *parent) : QDialog(parent), m_slider(new QSlider(Qt::Horizontal, this)) {
setWindowTitle("change value");
QVBoxLayout *layout = new QVBoxLayout(this); // 创建一个垂直布局
label = new QLabel(this);
layout->addWidget(label);
layout->addWidget(m_slider); // 将滑动条添加到布局中
setLayout(layout); // 将布局设置给当前的弹窗
}
QSlider* SliderDialog::slider() const {
return m_slider;
}
void SliderDialog::setText(QString text)
{
label->setText(text);
}
// 设置滑动条的范围
void SliderDialog::setRange(int min, int max)
{
m_slider->setRange(min, max);
}
void SliderDialog::setInitValue(int initValue)
{
m_slider->setValue(initValue);
}