paysages3d/gui_qt/inputint.cpp
2012-01-08 10:31:01 +00:00

47 lines
1 KiB
C++

#include "inputint.h"
#include <QLabel>
InputInt::InputInt(QWidget* form, QString label, int* value, int min, int max, int small_step, int large_step):
BaseInput(form, label),
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
{
slider = new QSlider(form);
slider->setOrientation(Qt::Horizontal);
slider->setMinimumWidth(150);
slider->setMaximumWidth(400);
slider->setMinimum(min);
slider->setMaximum(max);
slider->setValue(*value);
slider->setTickInterval(large_step);
slider->setTickPosition(QSlider::TicksBelow);
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
_preview = new QLabel(form);
_control = slider;
}
void InputInt::updatePreview()
{
((QLabel*)_preview)->setText(QString("%1").arg(*value));
BaseInput::updatePreview();
}
void InputInt::applyValue()
{
*value = (int)slider->value();
BaseInput::applyValue();
}
void InputInt::revert()
{
slider->setValue(*value);
BaseInput::revert();
}