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 i can convert int to QString
Forum Updated to NodeBB v4.3 + New Features

How i can convert int to QString

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 62.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    samlion007
    wrote on last edited by
    #1

    I maked my function to convert int to QString like:

    @
    QString convertInt(int number)
    {
    if (number == 0)
    return "0";
    QString temp="";
    QString returnvalue="";
    while (number>0)
    {
    temp+=number+48;
    number/=10;
    }
    for (int i=0;i<temp.length();i++)
    returnvalue+=temp[temp.length()-i-1];
    return returnvalue;
    }
    @

    my quis. is there any function more easy then this.

    Thanks

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Scylla
      wrote on last edited by
      #2
      1. QString tmp = QString::number(myInt)
      2. QString tmp = tr("%1").arg(myInt)
      1 Reply Last reply
      1
      • S Offline
        S Offline
        samlion007
        wrote on last edited by
        #3

        Thank you so much,it works

        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