c++ - 将 qint64 转换为 QString

标签 c++ qt qt4 qstring qtcore

对于其他类型我可以很容易地做类似的事情

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

是否有类似的函数将 qint64 转换为 QString?您可以在下面找到代码。

    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("]");

我已经注释掉了破坏代码的行。我对日期有同样的问题,但使用 toString 来转换它。我希望 qint64 也有类似的解决方案。

最佳答案

您可能正在寻找 QString::number(qlonglong, int) .

关于c++ - 将 qint64 转换为 QString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18992654/

相关文章:

c++ - ifstream 参数 - C++

javascript - 我无法在 QML 中滑动屏幕动画

qt - 带 Qt5 的 glewInit 返回缺少 GL 版本

ruby - Ruby 中的 Qt Model/View 编程示例和教程

c++ - Windows 风格的 getopt/argp

带递归的 C++ 平方根

c++ - 如何在不可见模式下运行 qt c++ 控制台应用程序?

c++ - qt4宏检测KDE或GNOME

c++ - 需要对 std::tuple(即 std::get<E>)进行非常量索引访问的 Eloquent 解决方案

c++ - 无法连接 Qt 与数据库 (SQLite)