Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use void QTextStream::setRealNumberNotation

How to use void QTextStream::setRealNumberNotation

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Try

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

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      5
      • tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by
        #3

        Thank you. Please have a look at these:

        QString s;
        QTextStream ss(&s);
        ss.setRealNumberNotation(QTextStream::SmartNotation);
        ss << 1000000;
        result_box -> setText(s);
        

        Here the result is: 1000000
        But in this one:

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

        The result is: 1e+06 !!!

        Why? And how to solve it please?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • tomyT Offline
            tomyT Offline
            tomy
            wrote on last edited by
            #5

            OK, thanks.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved