Michaël Lemaire
323dc8122c
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@357 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
48 lines
1.1 KiB
C++
48 lines
1.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);
|
|
((QLabel*)_preview)->setAlignment(Qt::AlignCenter);
|
|
_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();
|
|
}
|