Important: Please read the Qt Code of Conduct -

How to use void QTextStream::setRealNumberNotation

  • Hi,

    I need to use void QTextStream::setRealNumberNotation(RealNumberNotat ion notation). I looked at so-called Docs for it, but there is no example for beginners! (It's here:)

    For example:

    QString ss;
    QTextStream (&ss);
     // here to use it

    How to use it please?

  • Qt Champions 2017


    ss.setRealNumberNotation(QTextStream::ScientificNotation) or ss.setRealNumberNotation(QTextStream::FixedNotation) or

  • Thank you. Please have a look at these:

    QString s;
    QTextStream ss(&s);
    ss << 1000000;
    result_box -> setText(s);

    Here the result is: 1000000
    But in this one:

    QString s;
    double d = 1000000;
    QTextStream ss(&s);
    ss << d;
    result_box -> setText(s);

    The result is: 1e+06 !!!

    Why? And how to solve it please?

  • Lifetime Qt Champion


    You're not using the same types in both code sample. Once you send an integer and next a double. setRealNumberNotation affects float and double, not integers.

  • OK, thanks.

  • Lifetime Qt Champion

    You're welcome !

    If that answers your question then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)

Log in to reply