diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:17:53 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-07-10 15:17:53 -0500 |
commit | 37e3f157c7d76f13de807fa66e36df209e1005fb (patch) | |
tree | 7a4f131b2ee065337dac341bff34515310efba4f /experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h | |
parent | 16630c3eff313238fa8412275555285c9195981b (diff) | |
download | tde-37e3f157c7d76f13de807fa66e36df209e1005fb.tar.gz tde-37e3f157c7d76f13de807fa66e36df209e1005fb.zip |
Added TQt4 HEAD
Diffstat (limited to 'experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h')
-rw-r--r-- | experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h b/experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h new file mode 100644 index 000000000..7a451ee9b --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/designer/examples/metric/metric.ui.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions respectively Q_SLOTS use +** TQt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + +#include <tqvalidator.h> + +void ConversionForm::init() +{ + numberLineEdit->setValidator( new TQDoubleValidator( numberLineEdit ) ); + numberLineEdit->setText( "10" ); + convert(); + numberLineEdit->selectAll(); +} + +void ConversionForm::convert() +{ + enum MetricUnits { + Kilometers, + Meters, + Centimeters, + Millimeters + }; + enum OldUnits { + Miles, + Yards, + Feet, + Inches + }; + + // Retrieve the input + double input = numberLineEdit->text().toDouble(); + double scaledInput = input; + + // internally convert the input to millimeters + switch ( fromComboBox->currentItem() ) { + case Kilometers: + scaledInput *= 1000000; + break; + case Meters: + scaledInput *= 1000; + break; + case Centimeters: + scaledInput *= 10; + break; + } + + //convert to inches + double result = scaledInput * 0.0393701; + + switch ( toComboBox->currentItem() ) { + case Miles: + result /= 63360; + break; + case Yards: + result /= 36; + break; + case Feet: + result /= 12; + break; + } + + // set the result + int decimals = decimalsSpinBox->value(); + resultLineEdit->setText( TQString::number( result, 'f', decimals ) ); + numberLineEdit->setText( TQString::number( input, 'f', decimals ) ); +} + |