Pregunta

I want to display a numerical value in a QPlainTextEdit object. I use below code for this purpose.

QString s;
s.sprintf("%d", deneme); //deneme is an integer value.
ui->results->setPlainText(s);

Is there any other method for displaying integer and float numbers in a QPlainTextEdit without defining a new QString object.

Thanks.

¿Fue útil?

Solución

QString::number()

You still have to create a QString instance (that is what QPlainTextEdit requires), but this may be at least a little more convenient.

There are a bunch of overloads of that method to accommodate various input and output formats.

Otros consejos

How about:

ui->results->setPlainText(QString("%1").arg(deneme));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top