In a program, I want to display the number "0.12345
" as ".12345
" (removing the first zero) in a lineEdit
. For this I wrote the simple code below:
QString s;
QTextStream ss(&s);
double temp = 0.12345;
int n = 0;
if(temp > 0)
{
ss << ".";
while (true)
{
temp *= 10;
n = temp;
if (temp == n)
break;
}
ss << n;
}
lineEdit->setText(s);
When I run it, the program and Qt Creator hang and I need to rerun it to normally go out of it.
What is the problem that the program acts that way, please?