Results 1 to 3 of 3

Thread: How to convert Int to QString in QT4?

  1. #1
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Red face How to convert Int to QString in QT4?

    Sorry, but I am completely a noob using QT, I need to know how to convert an int to QString, using vcl from Borland was intToStr(value), but in QT4 how can I do it?

    I QTAsistant I read something about using QVariant, but I need help.

    thanks...

  2. #2
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to convert Int to QString in QT4?

    Hey guys, I find a way, but I don't know if it's the best, anyway I did the following:

    Qt Code:
    1. QVariant tempAge( listSE->getNode(i)->getData().getAge());
    2. QString age( tempAge.toString() );
    To copy to clipboard, switch view to plain text mode 

    Is there another way to do this?
    thanks!!!

  3. #3
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to convert Int to QString in QT4?

    Lots of ways. The easiest in my opinion is the static method:

    QString::number(int);

  4. The following 3 users say thank you to Brandybuck for this useful post:

    AgentGreen (19th July 2010), drake1983 (11th March 2007), tpf80 (18th May 2007)

Similar Threads

  1. How to convert from QString to string ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 1st December 2010, 02:50
  2. Cannot convert double to QString
    By maxpower in forum Qt Programming
    Replies: 9
    Last Post: 24th December 2007, 04:04
  3. Convert wstring to QString.
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2007, 15:18
  4. Replies: 2
    Last Post: 12th June 2006, 18:47
  5. How to convert from QString to quint16 ?
    By probine in forum Qt Programming
    Replies: 5
    Last Post: 31st March 2006, 10:00

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.