qt,spinbox slider

#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)