5 #include "qui/ThresholdWidget.hpp"
7 // This is completely and totally derived from the Qt example
9 ThresholdWidget::ThresholdWidget(QWidget *parent, int min, int max)
12 QLCDNumber *lcd = new QLCDNumber(threshold_max_display_digits);
13 lcd->setSegmentStyle(QLCDNumber::Flat);
15 slider = new QSlider(Qt::Horizontal);
16 slider->setRange(min, max);
18 connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));
19 connect(slider, SIGNAL(valueChanged(int)),
20 this, SIGNAL(thresholdChanged(int)));
22 slider->setValue(min);
25 QHBoxLayout *layout = new QHBoxLayout;
26 layout->addWidget(slider);
27 layout->addWidget(lcd);
31 void ThresholdWidget::setMinimumThreshold(int min)
33 slider->setMinimum(min);
36 int ThresholdWidget::getMinimumThreshold()
38 return slider->minimum();
41 void ThresholdWidget::setMaximumThreshold(int max)
43 slider->setMaximum(max);
46 int ThresholdWidget::getMaximumThreshold()
48 return slider->maximum();
51 void ThresholdWidget::setRange(int min, int max)
53 slider->setRange(min, max);
56 float ThresholdWidget::percent() const
58 return ((float)threshold())/((float)slider->maximum());
61 void ThresholdWidget::setThreshold(int threshold)
63 if (slider->value() != threshold)
65 slider->setValue(threshold);
66 emit thresholdChanged(threshold);
70 int ThresholdWidget::threshold() const
72 return slider->value();