indicador de volumen con dos decimales
This commit is contained in:
parent
32a1e5cb0c
commit
3613d8fa51
12 changed files with 53 additions and 187 deletions
|
@ -3,6 +3,7 @@
|
|||
SliderGroup::SliderGroup(const QString &title, \
|
||||
int min,
|
||||
int max,
|
||||
int decimals,
|
||||
QWidget *parent)
|
||||
: QGroupBox(title, parent)
|
||||
{
|
||||
|
@ -14,17 +15,31 @@ SliderGroup::SliderGroup(const QString &title, \
|
|||
slider->setTickInterval((max - min) / 11);
|
||||
slider->setSingleStep(1);
|
||||
slider->setRange(min, max);
|
||||
//slider->setInvertedAppearance(false);
|
||||
//slider->setInvertedControls(false);
|
||||
valueBox = new QSpinBox();
|
||||
valueBox = new QDoubleSpinBox();
|
||||
valueBox->setFocusPolicy(Qt::NoFocus);
|
||||
valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
valueBox->setMaximumWidth(40);
|
||||
valueBox->setMaximumWidth(45);
|
||||
valueBox->setRange(min, max);
|
||||
connect(slider, &QSlider::valueChanged, valueBox, &QSpinBox::setValue);
|
||||
valueBox->setDecimals(decimals);
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int)));
|
||||
QVBoxLayout *slidersLayout = new QVBoxLayout();
|
||||
slidersLayout->addWidget(valueBox);
|
||||
slidersLayout->addWidget(slider);
|
||||
setLayout(slidersLayout);
|
||||
}
|
||||
|
||||
void SliderGroup::sliderValueChanged(int value)
|
||||
{
|
||||
if (valueBox->decimals() > 1)
|
||||
value /= 100.0f;
|
||||
emit valueChanged(value);
|
||||
valueBox->setValue(value);
|
||||
};
|
||||
|
||||
void SliderGroup::setValue(float value)
|
||||
{
|
||||
if (valueBox->decimals() > 1)
|
||||
value *= 100.0f;
|
||||
slider->setValue(value);
|
||||
valueBox->setValue(value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue