QString & QString::sprintf(const char * cformat, …)
与C语言中的sprintf()函数类似
#if 1
QStringList hheader;
for(int i=0;i<64;i++)
{
hheader<<QString("%1").sprintf("%02d",i); //02表示显示几位数
}
qDebug()<<"hheader= "<<hheader ;
QString con = QString("52");
int k = hheader.indexOf(con);
qDebug()<<"k == "<<k;
float v;
v=(1048*1.00)/2048;
QString celltext[32];
qDebug()<<"float v= "<<v;
celltext[0] = QString().sprintf("%0.3f",v);
qDebug()<<"celltext float = "<<celltext[0];
celltext[0] = QString().sprintf("0x%02x",v);
qDebug()<<" celltext hex "<< celltext[0] ;
for(int i = 0; i<10;i++)
{
celltext[i] = QString().sprintf("0x%02x",0-i);
}
qDebug()<<" celltext hex = \n"
<< celltext[0]<<" "<<celltext[1]<<" "<< celltext[2]<<" "<< celltext[3]<<" "<< celltext[4]<<" \n"
<< celltext[5]<<" "<<celltext[6]<<" "<< celltext[7]<<" "<< celltext[8]<<" "<< celltext[9]<<" \n";
for(int i =0 ; i<32;i++)
{
celltext[i] = QString().sprintf("0x%02x",i);
}
qDebug()<<" celltext hex = \n"
<< celltext[0]<<" "<<celltext[1]<<" "<< celltext[2]<<" "<< celltext[3]<<" "<< celltext[4]<<" \n"
<< celltext[5]<<" "<<celltext[6]<<" "<< celltext[7]<<" "<< celltext[8]<<" "<< celltext[9]<<" \n"
<< celltext[10]<<" "<<celltext[11]<<" "<< celltext[12]<<" "<< celltext[13]<<" "<< celltext[14]<<" \n"
<< celltext[15]<<" "<<celltext[16]<<" "<< celltext[17]<<" "<< celltext[18]<<" "<< celltext[19]<<" \n"
<< celltext[20]<<" "<<celltext[21]<<" "<< celltext[22]<<" "<< celltext[23]<<" "<< celltext[24]<<" \n"
<< celltext[25]<<" "<<celltext[26]<<" "<< celltext[27]<<" "<< celltext[28]<<" "<< celltext[29]<<" \n"
<< celltext[30]<<" "<<celltext[31];
#endif