不知道出了什么问题,Slider与SpinBox无法同步,请大侠指点一二!
代码如下:
#include <QApplication>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QWidget *window = new QWidget;
window->setWindowTitle("This is WindowLayout test");
QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinBox->setRange(0,120);
slider->setRange(0,120);
QObject::connect(spinBox,SIGNAL(ValueChanged(int)),
slider,SLOT(setValue(int)));
QObject::connect(slider,SIGNAL(ValueChanged(int)),
spinBox,SLOT(setValue(int)));
spinBox->setValue(30);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->show();
return app.exec();
}
插入运行的截图如下:

请大侠指点一下,郁闷ing