123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "sens.h"
- #include <QLCDNumber>
- #include <QSlider>
- #include <QGridLayout>
- Sens::Sens(QWidget *parent) :
- QWidget(parent)
- {
- QLCDNumber *lcd = new QLCDNumber(2);
- lcd->setSegmentStyle(QLCDNumber::Flat);
- lcd->display(5);
- QSlider *slider = new QSlider(Qt::Vertical);
- slider->setRange(1,10);
- slider->setValue(5);
- connect(slider,SIGNAL(valueChanged(int)),
- lcd,SLOT(display(int)));
- //connect(slider,SIGNAL(valueChanged(int)),
- //this,SLOT(setValue(int)));
- QGridLayout *grid = new QGridLayout();
- grid->addWidget(lcd,0,1);
- grid->addWidget(slider,0,0,0,1);
- //grid->setColumnStretch(1,1);
- grid->setRowStretch(0,10);
- grid->addItem(new QSpacerItem(100, 50, QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding),1, 1);
- this->setLayout(grid);
- }
- void Sens::setRange(int minValue, int maxValue)
- {
- if (minValue < 1 || maxValue > 11|| minValue > maxValue) {
- qWarning("LCDRange::setRange(%d, %d)\n"
- "\tRange must be 0..10\n"
- "\tand minValue must not be greater than maxValue",
- minValue, maxValue);
- return;
- }
- slider->setRange(minValue, maxValue);
- }
- int Sens::value() const
- {
- return slider->value();
- }
- void Sens::setValue(int value)
- {
- slider->setValue(value);
- }
|