Results 1 to 4 of 4

Thread: very small qreal number

  1. #1
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default very small qreal number

    How can i disable the exponential notation? for example, if i get the topleft corner(QPointF) of a QGraphicsrectitem i couldn't have this kind of result:

    QPointF(-1.06581e-14,12); but QPointF(-0.000000000"...",12); where the x coordinate is truncated at the ith position.....

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: very small qreal number

    You did not tell us, how you want to output that stuff... we have to guess what your problem is.

    Anyway, have a look at QTextStream::setRealNumberNotation
    HTH

  3. #3
    Join Date
    Feb 2008
    Posts
    102
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: very small qreal number

    I read and generate number with a QTextstream so i use this code to resolve the problem:
    Qt Code:
    1. QTextStream out("some file");
    2. out.setRealNumberPrecision ( 5 );
    To copy to clipboard, switch view to plain text mode 

    The default real number precision is '6' that put in some case, the exponential "e" notation........setting it on '5' it doesn't appear.......
    Is it just a case or is there a reason??

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: very small qreal number

    A clear case of "read the docs".

    The default for QTextStream::setRealNumberNotation is QTextStream::SmartNotation.
    (Checked the source...)

    TextStream::SmartNotation => Scientific or fixed-point notation, depending on which makes most sense (printf()'s %g flag).

    So, the answer "why" your code behaves like it does is probably given by "man 2 printf".

Similar Threads

  1. Line Number - QTextEdit...???
    By deepusrp in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 16:34
  2. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.