#include "myapp.h"
#include <QtGui/QApplication>
#include <QtGui/QHBoxLayout>
#include <QtGui/QSlider>
#include <QtGui/QSpinBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// 将QWidget对象作为主窗口
QWidget *window = new QWidget;
window->setWindowTitle("Enter Your Name");
// 设置spinBox和slide
QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinBox->setRange(0, 130);
slider->setRange(0, 130);
// 设置信号与槽
QObject::connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
// 设置初始值
spinBox->setValue(35);
// 将spinBox和slider放入布局中
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->show();
return a.exec();
}