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;
}
Exemplo n.º 3
0
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;
}