1.uint64转QString
QString strfilerename = QString("%1").arg(nFileID); //nFileID为uint64类型
QString::number( nFileID);
2.QString转超长数字串
QString a=123456789012345;
uint64 nB = a.toULongLong();
3.uint64_t 转std::string
std::to_string(nFileID); //nFileID为uint64_t类型
4.std::string 转 uint64_t(或unsigned)
unsigned long strtoul( const char *str, char **str_end, int base ); |
|
|
unsigned long long strtoull( const char *str, char **str_end, int base ); |
std::string SuccessDataName;
uint64_t unJobID = std::strtoull(SuccessDataName.c_str(), NULL, 10);
//base 的合法集是 {0,2,3,...,36};base为 0 ,则自动检测数值进制:若前缀为 0
,则底为八进制(可参考八进制表示方法),若前缀为 0x
或 0X
,则底为十六进制,否则底为十进制。
5.QString与Std::String
QString strFilePath=QString::fromStdString(strFileDirectory); //strFileDirectory为Std::String类型
Std::String strFileDirectory=strFilePath.tostdString();//strFilePath为QString类型。
6.内存数据转换为输入流
需要添加头文件
#include <strstream>
using namespace std;
//假设pData指向了内存中你想要转变为流的数据
//iLen是数据长度
strstreambuf buff(pData, iLen);
istream xmlStream(&buff); //xmlStream也就是你要的流了
7. QDateTime 转QString
#include <QDateTime>
QDateTime tEstimatedTime;
f (tEstimatedTime.toSecsSinceEpoch() == 0)
{
return " ";
}
else
{
return tEstimatedTime.toString("yyyy/M/d HH:mm:ss");
}