Quantcast
Channel: Qt DevNet forums: Installation and Deployment
Viewing all articles
Browse latest Browse all 2113

Problem to convert Float or Double to String in QLineEdit

$
0
0
Dear community, I have make an operation to calculate but when the amount is more than 1 million, the QLineEdit don’t show all the number. Example : 1000000 = 1e+06. This is the code I have written void PersoInfo::on_CalculOp_clicked() { //Permet de calculer une variable float et afficher le resultat     //Proceder convertir String en float et enfin float en String         QString str1,str2,str4,str5,str7,str8;            str1=ui->txt_Prix_Salle->text();          str2=ui->txt_Duree_Salle->text();          str4=ui->txt_Prix_Chambre->text();          str5=ui->txt_Duree_Chambre->text();          str7=ui->txt_Prix_Restau->text();          str8=ui->txt_Qte_Restau->text();           float Csal,Ccha,Cres,Net,Tva;          float Psal = str1.toFloat();          float Dsal = str2.toFloat();          float Pcha = str4.toFloat();          float Dcha = str5.toFloat();          float Pres = str7.toFloat();          float Qres = str8.toFloat();              Csal = Psal * Dsal;          Ccha = Pcha * Dcha;          Cres = Pres * Qres;          Net = Csal + Ccha + Cres ;          Tva = ((Net * 18) / 100);            QString str3 = QString::number(Csal);          ui->txt_Total_Salle->setText(str3);            QString str6 = QString::number(Ccha);          ui->txt_Total_Chambre->setText(str6);            QString str9 = QString::number(Cres);          ui->txt_Total_Restau->setText(str9);            QString str0 = QString::number(Net);          ui->txt_Net_Caisse->setText(str0);            QString str10 = QString::number(Tva);          ui->txt_Tva_Caisse->setText(str10); } Thanks to help me [edit: added missing coding tags @ SGaist]

Viewing all articles
Browse latest Browse all 2113

Trending Articles