Results 1 to 3 of 3

Thread: How to convert an int or uint to QString. (qt4.1.1, SuSe 10, gcc 4.0.2)

  1. #1
    Join Date
    Feb 2006
    Posts
    25
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to convert an int or uint to QString. (qt4.1.1, SuSe 10, gcc 4.0.2)

    Hey guys,

    How do you go about converting a uint or int to a QString?

    Thanks in advanced.

  2. #2
    Join Date
    Jan 2006
    Location
    N.B. Canada
    Posts
    47
    Thanked 8 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to convert an int or uint to QString. (qt4.1.1, SuSe 10, gcc 4.0.2)

    use one of setNum methods:

    http://doc.trolltech.com/4.1/qstring.html#setNum

    Bojan
    The march of progress:
    C:
    printf("%10.2f", x);
    C++:
    cout << setw(10) << setprecision(2) << showpoint << x;
    Java:
    java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
    formatter.setMinimumFractionDigits(2);
    formatter.setMaximumFractionDigits(2);
    String s = formatter.format(x);
    for (int i = s.length(); i < 10; i++) System.out.print(' ');
    System.out.print(s);

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

    freak (13th June 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to convert an int or uint to QString. (qt4.1.1, SuSe 10, gcc 4.0.2)

    Or use QString::number() static method.

  5. The following user says thank you to wysota for this useful post:

    freak (13th June 2006)

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.