Search code examples
qtqt-creatorqstringqplaintextedit

Displaying integer and float numbers in a QPlainTextEdit object


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.


Solution

  • 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.