PDA

View Full Version : How to send the output(say average) to a lineEdit?



enthudrives
15th June 2010, 12:26
Hi everyone. I am new to qt programming.
I want to compute the average and display the output using a lineEdit.
I used


ui->lineEdit->setText(QString::number(avg));

This displays the output without decimals. How to display float in lineEdit?

Thanks in advance..

high_flyer
15th June 2010, 12:54
There are several overloaded QString::number() variants.
have a looks at this one:
http://doc.trolltech.com/4.6/qstring.html#number-2

enthudrives
15th June 2010, 13:21
Thanks .
I got it


ui->lineEdit->setText(QString::number(avg,'f',2));