1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| DoubleSpinBoxSupport::DoubleSpinBoxSupport( QWidget * parent):QDoubleSpinBox(parent)
{
connect(this, SIGNAL(changevaluetomax_si()), this, SLOT(changevaluetomax_sl()) );
}
QValidator::State DoubleSpinBoxSupport::validate( QString & input, int & pos ) const
{
//il y a un suffix de 2 caractères
if(input.length()>2)
{
QString newtext = input.left(input.length()-2);
if( newtext.toDouble()>this->maximum() )
{
emit changevaluetomax_si();
return QValidator::Acceptable;
}
}
return QDoubleSpinBox::validate(input, pos);
}
void DoubleSpinBoxSupport::changevaluetomax_sl()
{
this->setValue(this->maximum());
} |
Partager