#include <QApplication>
#include <QtGui>
int main(int argc,char * argv[])
{
QApplication app(argc,argv);
QWidget * window = new QWidget;
window->setWindowTitle("Enter your age");
QSpinBox * spinBox = new QSpinBox;
spinBox->setRange(0,300);
QSlider * slider = new QSlider(Qt::Vertical);
slider->setRange(0,300);
QSlider * slider1 = new QSlider(Qt::Horizontal);
slider1->setRange(0,300);
QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
QObject::connect(slider1,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider1,SLOT(setValue(int)));
QObject::connect(slider1,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
QObject::connect(slider,SIGNAL(valueChanged(int)),slider1,SLOT(setValue(int)));
spinBox->setValue(55);
QHBoxLayout * layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
layout->addWidget(slider1);
window->setLayout(layout);
window->show();
return app.exec();
}
qt,spinbox slider
最新推荐文章于 2024-04-27 19:21:10 发布