rangectldemo.cpp
#include <QtGui>
#include <QtDebug>
#include "rangectldemo.h"
RangeCtlDemo::RangeCtlDemo()
{
mySlider = new QSlider(Qt::Horizontal);
mySlider->setRange(0, 99);
mySlider->setValue(0);
myDial = new QDial;
myDial->setRange(0, 99);
myDial->setValue(0);
myScrollbar = new QScrollBar(Qt::Horizontal);
myScrollbar->setRange(0, 99);
myScrollbar->setValue(0);
mySpinbox = new QSpinBox;
mySpinbox->setRange(0, 99);
mySpinbox->setValue(0);
myProgressbar = new QProgressBar;
myProgressbar->setRange(0, 99);
myProgressbar->setValue(0);
myLcd = new QLCDNumber;
myLcd->display(0);
connect(mySlider, SIGNAL(valueChanged(int)), this, SLOT(RangeAdj(int)));
connect(myDial, SIGNAL(valueChanged(int)), this, SLOT(RangeAdj(int)));
connect(myScrollbar, SIGNAL(valueChanged(int)), this, SLOT(RangeAdj(int)));
connect(mySpinbox, SIGNAL(valueChanged(int)), this, SLOT(RangeAdj(int)));
connect(mySpinbox, SIGNAL(valueChanged(int)), myProgressbar, SLOT(setValue(int)));
connect(mySpinbox, SIGNAL(valueChanged(int)), myLcd, SLOT(display(int)));
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(mySlider,0, 0);
layout->addWidget(myDial,1, 0);
layout->addWidget(myScrollbar,2,0);
layout->addWidget(mySpinbox,3,0);
layout->addWidget(myProgressbar,4,0);
layout->addWidget(myLcd,5,0);
layout->addStretch(1);
setLayout(layout);
}
void RangeCtlDemo::RangeAdj(const int val)
{
mySlider->setValue(val);
myDial->setValue(val);
myScrollbar->setValue(val);
mySpinbox->setValue(val);
//myProgressbar->setValue(5);
//myLcd->display(val);
//qDebug() << val;
}