Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How i can convert int to QString
Qt 6.12 LTS is out! See what's new in the release blog

How i can convert int to QString

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 70.3k 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.
  • ? Offline
    ? Offline
    A Former User
    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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2
      1. QString tmp = QString::number(myInt)
      2. QString tmp = tr("%1").arg(myInt)
      1 Reply Last reply
      1
      • ? Offline
        ? Offline
        A Former User
        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
        • Unsolved