-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsliderfloat.cpp
More file actions
54 lines (44 loc) · 1.11 KB
/
sliderfloat.cpp
File metadata and controls
54 lines (44 loc) · 1.11 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
#include "sliderfloat.h"
#include "ui_sliderfloat.h"
sliderFloat::sliderFloat(QWidget *parent) :
QWidget(parent),
ui(new Ui::sliderFloat)
{
ui->setupUi(this);
divisor=1;
defaultValue=0;
}
sliderFloat::~sliderFloat()
{
delete ui;
}
void sliderFloat::setText(QString text){
ui->label->setText(text);
}
void sliderFloat::setRange(int min, int max,int divisor){
this->divisor=divisor;
ui->horizontalSlider->setRange(min,max);
ui->doubleSpinBox->setRange((float)min/divisor,(float)max/divisor);
}
float sliderFloat::getValue(){
return (float)(ui->horizontalSlider->value())/divisor;
}
void sliderFloat::setDefaultValue(float value){
ui->horizontalSlider->setValue(value*divisor);
ui->doubleSpinBox->setValue(value);
defaultValue=value;
}
void sliderFloat::on_horizontalSlider_valueChanged(int value)
{
ui->doubleSpinBox->setValue((float)value/divisor);
}
void sliderFloat::on_pushButton_clicked()
{
setDefaultValue(defaultValue);
}
QSlider* sliderFloat::getSlider(){
return ui->horizontalSlider;
}
QPushButton* sliderFloat::getButton(){
return ui->pushButton;
}