How i can convert int to QString



  • 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. QString tmp = QString::number(myInt)
    2. QString tmp = tr("%1").arg(myInt)


  • Thank you so much,it works


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.