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; }
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); }
QwtSlider *Slider::createSlider(QWidget *parent, int sliderType) const { QwtSlider *slider = NULL; switch(sliderType) { case 0: { slider = new QwtSlider(parent, Qt::Horizontal, QwtSlider::TopScale, QwtSlider::BgTrough); slider->setThumbWidth(10); slider->setRange(-10.0, 10.0, 1.0, 0); // paging disabled break; } case 1: { slider = new QwtSlider(parent, Qt::Horizontal, QwtSlider::NoScale, QwtSlider::BgBoth); slider->setRange(0.0, 1.0, 0.01, 5); break; } case 2: { slider = new QwtSlider(parent, Qt::Horizontal, QwtSlider::BottomScale, QwtSlider::BgSlot); slider->setThumbWidth(25); slider->setThumbLength(12); slider->setRange(1000.0, 3000.0, 10.0, 10); break; } case 3: { slider = new QwtSlider(parent, Qt::Vertical, QwtSlider::LeftScale, QwtSlider::BgSlot); slider->setRange(0.0, 100.0, 1.0, 5); slider->setScaleMaxMinor(5); break; } case 4: { slider = new QwtSlider(parent, Qt::Vertical, QwtSlider::NoScale, QwtSlider::BgTrough); slider->setRange(0.0,100.0,1.0, 10); break; } case 5: { slider = new QwtSlider(parent, Qt::Vertical, QwtSlider::RightScale, QwtSlider::BgBoth); slider->setScaleEngine(new QwtLog10ScaleEngine); slider->setThumbWidth(20); slider->setBorderWidth(1); slider->setRange(0.0, 4.0, 0.01); slider->setScale(1.0, 1.0e4); slider->setScaleMaxMinor(10); break; } } return slider; }
QwtSlider * createSlider (int sliderType) { QwtSlider * slider = new QwtSlider(); switch( sliderType ) { case 0: { slider->setOrientation( Qt::Horizontal ); slider->setScalePosition( QwtSlider::TrailingScale ); slider->setTrough( true ); slider->setGroove( false ); slider->setSpacing( 0 ); slider->setHandleSize( QSize( 30, 16 ) ); slider->setScale( 10.0, -10.0 ); slider->setTotalSteps( 8 ); slider->setSingleSteps( 1 ); slider->setPageSteps( 1 ); slider->setWrapping( true ); break; } case 1: { slider->setOrientation( Qt::Horizontal ); slider->setScalePosition( QwtSlider::NoScale ); slider->setTrough( true ); slider->setGroove( true ); slider->setScale( 0.0, 1.0 ); slider->setTotalSteps( 100 ); slider->setSingleSteps( 1 ); slider->setPageSteps( 5 ); break; } case 2: { slider->setOrientation( Qt::Horizontal ); slider->setScalePosition( QwtSlider::LeadingScale ); slider->setTrough( false ); slider->setGroove( true ); slider->setHandleSize( QSize( 12, 25 ) ); slider->setScale( 1000.0, 3000.0 ); slider->setTotalSteps( 200.0 ); slider->setSingleSteps( 2 ); slider->setPageSteps( 10 ); break; } case 3: { slider->setOrientation( Qt::Horizontal ); slider->setScalePosition( QwtSlider::TrailingScale ); slider->setTrough( true ); slider->setGroove( true ); QwtLinearScaleEngine *scaleEngine = new QwtLinearScaleEngine( 2 ); scaleEngine->setTransformation( new QwtPowerTransform( 2 ) ); slider->setScaleEngine( scaleEngine ); slider->setScale( 0.0, 128.0 ); slider->setTotalSteps( 100 ); slider->setStepAlignment( false ); slider->setSingleSteps( 1 ); slider->setPageSteps( 5 ); break; } } if (slider) { QString name( "Slider %1" ); slider->setObjectName( name.arg( sliderType ) ); } return slider; }