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);
}
Esempio n. 3
0
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;
}