Results 1 to 3 of 3

Thread: How to change the display format of numbers on axis?

  1. #1
    Join Date
    Jan 2012
    Location
    ShangHai, PRC of China
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to change the display format of numbers on axis?

    I'm trying to show a range -32768.0, 32767.0 on right Y axis:
    Qt Code:
    1. setAxisScale(yRight, -32768.0, 32767.0);
    To copy to clipboard, switch view to plain text mode 
    But if the value is 10000, it will displayed as 10,000. In fact I don't want the comma to be shown. How to change the display format? It seems there's no such an interface.

    axis.jpg

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,200
    Thanked 848 Times in 797 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to change the display format of numbers on axis?

    Quote Originally Posted by wang9658 View Post
    In fact I don't want the comma to be shown. How to change the display format?
    How numbers are converted to strings depends on the locale of the runtime environment. So this is something that depends on the preferences of the user of the application - not on the taste of the application developer. That's why you shouldn't hardcode something when your application is intended to run in different countries ( or at least by users with different nationalities ).

    But in situations, where you want to ignore the environment you can modify the locale ( see QLocale or google for i18n ). This has an effect on many C-library functions ( like sprinf() ) and for QString conversions as well. If you want to manipulate the displayed labels in a way that has nothing to do with i18n you can overload and reimplement QwtScaleDraw::label().

    HTH,
    Uwe

  3. The following user says thank you to Uwe for this useful post:

    wang9658 (26th January 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    ShangHai, PRC of China
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to change the display format of numbers on axis?

    Thank you for your reply. You let me see sth should depend on the runtime enviroment but not the developper. So I will do as it is. Very thanks again.

    Kevin

Similar Threads

  1. How to display the numbers in a QList<QString> ?
    By harish in forum Qt Programming
    Replies: 4
    Last Post: 3rd January 2012, 05:26
  2. Replies: 5
    Last Post: 12th August 2011, 23:55
  3. Replies: 12
    Last Post: 18th May 2011, 21:40
  4. Axis yLeft cuts of numbers
    By sun in forum Qwt
    Replies: 17
    Last Post: 9th October 2009, 22:36
  5. Numbers with comma format
    By baray98 in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2007, 20:45

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.