CQSpringLayoutParameterWindow::CQSpringLayoutParameterWindow(const QString &title, QWidget *parent , Qt::WindowFlags flags) : QDockWidget(title, parent, flags) { QWidget* pParaWidget = new QWidget(this); QVBoxLayout* pLayout = new QVBoxLayout; pParaWidget->setLayout(pLayout); size_t i; for (i = 0; i < mLayoutParameters.values.size(); ++i) { QLabel* label = new QLabel(mLayoutParameters.names[i].c_str()); pLayout->addWidget(label); #if QWT_VERSION > 0x060000 QwtSlider* slider = new QwtSlider(Qt::Horizontal, pParaWidget); slider->setScalePosition(QwtSlider::LeadingScale); if (mLayoutParameters.isLog[i]) slider->setScaleEngine(new QwtLogScaleEngine()); #else QwtSlider* slider = new QwtSlider(pParaWidget, Qt::Horizontal, QwtSlider::BottomScale); if (mLayoutParameters.isLog[i]) { slider->setScaleEngine(new QwtLog10ScaleEngine()); slider->setRange(log10(mLayoutParameters.min[i]), log10(mLayoutParameters.max[i])); slider->setScale(mLayoutParameters.min[i], mLayoutParameters.max[i]); } else { slider->setRange(mLayoutParameters.min[i], mLayoutParameters.max[i]); } #endif if (mLayoutParameters.isLog[i]) { slider->setScale(mLayoutParameters.min[i], mLayoutParameters.max[i]); slider->setValue(log10(mLayoutParameters.values[i])); } else { slider->setValue(mLayoutParameters.values[i]); } pLayout->addWidget(slider); mLayoutSliders.push_back(slider); connect(slider, SIGNAL(valueChanged(double)), this, SLOT(slotLayoutSliderChanged())); } setWidget(pParaWidget); setVisible(false); }
QWidget *SliderInterface::createWidget(QWidget *parent) { QwtSlider *slider = new QwtSlider(parent); #if 0 slider->setScalePosition(QwtSlider::Bottom); slider->setRange(0.0, 10.0, 1.0, 0); slider->setValue(3.0); #endif return slider; }