我添加QSlider
并QSpinBox
使用此代码
QSpinBox *spinner2 = new QSpinBox;
QSlider *slider2 = new QSlider(Qt::Vertical);
spinner2->setRange(2,100);
slider2->setRange(2,100);
QObject::connect(spinner2, SIGNAL(valueChanged(int)), slider2, SLOT(setValue(int)));
QObject::connect(slider2, SIGNAL(valueChanged(int)), spinner2, SLOT(setValue(int)));
spinner2->setValue(10);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(slider2);
layout->addWidget(spinner2);
我想添加其中的 30 个,如何循环添加?