Quick Help Needed with little App.
I need to make something that converts from Celcious to:
Kelvin, Fahrenheit, Rankine, Réaumur, Newton, Rømer and Delisle.
Right now, I have the following:
Code:
void mainForm::convertClicked()
{
double celsius_input, result = 0;
celsius_input = celsiusLineEdit->text().toDouble();
result = (celsius_input * (9.0/5.0)) + 32.0;
resultLineEdit
->setText
(QString::number(result,
'f',
1));
celsiusLineEdit->clear();
}
The problem is, all results have to come in that same resultLineEdit.
How do I do that?
Thanks.
Re: Quick Help Needed with little App.
Please, this is urgent.. Anyone?
Re: Quick Help Needed with little App.
Quote:
Originally Posted by
Sicko
Please, this is urgent..
Never and I mean never say something is urgent if you want a fast reply :cool:
How do you want to display all values in the same lineedit? And why a line edit and not a QLabel?
Try this:
Code:
float cel=0, kel=273.15, fahr=32.0; // make those members of your form
void mainForm::convert(){ // a slot
double input; // gather input here
bool fromCelsius = celsiusLineEdit->text().isEmpty() ? false : true;
// do the conversion
if(fromCelsius){
input = celsiusLineEdit->text().toDouble();
cel = input; // from Celsius
} else {
input = kelvinLineEdit->text().toDouble();
cel = input + 273.15; // from Kelvin
}
kel = 273.15+cel;
fahr = (9.0/5.0)*cel+32;
label
->setText
(QString("%1K, %2 deg. C, %3 deg. F").
arg(kel
).
arg(cel
).
arg(fahr
));
}
Re: Quick Help Needed with little App.
We have to use a textedit ...
Thanks (for the fast) reply tho
Re: Quick Help Needed with little App.
Quote:
Originally Posted by
Sicko
We have to use a textedit ...
Last time you said line edit... You can apply the answer the same way though.