Michaël Lemaire
1fcbb37f17
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@214 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#include "inputdouble.h"
|
|
|
|
#include <QLabel>
|
|
|
|
InputDouble::InputDouble(QWidget* form, QString label, double* value, double min, double max, double small_step, double large_step):
|
|
BaseInput(form, label),
|
|
value(value), min(min), max(max), small_step(small_step), large_step(large_step)
|
|
{
|
|
setObjectName("_form_doubleslider_");
|
|
|
|
slider = new QSlider(form);
|
|
|
|
slider->setOrientation(Qt::Horizontal);
|
|
slider->setMinimumWidth(150);
|
|
slider->setMaximumWidth(400);
|
|
|
|
slider->setMinimum(min / small_step);
|
|
slider->setMaximum(max / small_step);
|
|
slider->setValue(*value / small_step);
|
|
|
|
slider->setTickInterval(large_step / small_step);
|
|
slider->setTickPosition(QSlider::TicksBelow);
|
|
|
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(applyValue()));
|
|
|
|
_preview = new QLabel(form);
|
|
_control = slider;
|
|
}
|
|
|
|
void InputDouble::applyValue()
|
|
{
|
|
*value = ((double)slider->value()) * small_step;
|
|
((QLabel*)_preview)->setText(QString("%1").arg(*value));
|
|
emit(valueChanged());
|
|
}
|
|
|
|
void InputDouble::revert()
|
|
{
|
|
slider->setValue(*value / small_step);
|
|
}
|