QString的常用转换
.cpp
#include <QCoreApplication>
#include <QDebug>
#include <QDateTime>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString str("挪");
qDebug() << str;
//Qchar 数组初始化
QChar cHello[5] = {
'H','e','l','l','o'};
QString strHello(cHello,5);
qDebug()<< strHello;
qDebug()<< sizeof(QChar)<<sizeof(char);
//QString转int float double
QString strAge("22");
QString strPi("3.14");
int nAge = strAge.toInt();
float fPi = strPi.toFloat();
double dPI = strPi.toDouble();
qDebug() << "nAge:" << nAge;
qDebug() << "fPi:" << fPi;
qDebug() << "dPI:" << dPI;
//number 转 Qstring
int year = 1998;
int year2 =2021;
float height = 1.83f;
float widgth = 6.6f;
QString strYear,strYear2,strHeight,strWidth;
strYear = QString::number(year);
strYear2 = strYear2.setNum