#include "slidergroup.h" SliderGroup::SliderGroup(const QString &title, \ int min, int max, int decimals, QWidget *parent) : QGroupBox(title, parent) { this->setFlat(true); this->setTitle(title); slider = new QSlider(Qt::Orientation::Vertical); slider->setFocusPolicy(Qt::StrongFocus); slider->setTickPosition(QSlider::TicksBothSides); slider->setTickInterval((max - min) / 11); slider->setSingleStep(1); slider->setRange(min, max); valueBox = new QDoubleSpinBox(); valueBox->setFocusPolicy(Qt::NoFocus); valueBox->setButtonSymbols(QAbstractSpinBox::NoButtons); valueBox->setMaximumWidth(45); valueBox->setRange(min, max); 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); }