Convert qint64 to QString

Philip Kirkbride picture Philip Kirkbride · Sep 24, 2013 · Viewed 17.3k times · Source

With other types I could easily do something like

mitm.created().toString("yyyy-MM-dd")

Is there a similar function to turn a qint64 into a QString? You can find the code below.

    fileArray.append("[");
    foreach(QFileInfo mitm, mDir.entryInfoList(QDir::Files)){
        fileArray.append("{\"filePath\": \"");
        fileArray.append(mitm.absoluteFilePath());
        fileArray.append("\",");
        fileArray.append("\"fileCreated\": \"");
        fileArray.append(mitm.created().toString("yyyy-MM-dd"));
        fileArray.append("',");
        fileArray.append("'fileSize': '");
//      fileArray.append(mitm.size());
        fileArray.append("\"}");
        if(fileCount!=mDir.entryInfoList(QDir::Files).count()-1){ fileArray.append(","); }
        fileCount++;
    }
    fileArray.append("]");

I've commented out the line which breaks the code. I had the same problem with date but used toString to convert it. I was hoping there would be a similar solution for qint64.

Answer

RA. picture RA. · Sep 25, 2013

You are probably looking for QString::number(qlonglong, int).