Qt之指针与float--setNum使用

时间:2022-08-31 22:45:16

   案例:

   quint8 ad[8] = {0,100,150,200,0,220,230,250};

    QString str;
    QString str2;
    ab = (float)(*((float *)(ad)));
    ac = (float)(*((float *)(ad+4)));
    ae = (float)(*(float *)(gt));
    qDebug() << QString("%1 ").arg(ab, 0, 'f', 6)+" "+ QString("%1 ").arg(ac, 0, 'f', 6);
    qDebug() << QString("%1 ").arg(ae, 0, 'f', 6);
    str += str2.setNum(ab, 'f', 6) + " " + str2.setNum(ac,'f',6) + "\n"; //出现相同的结果值;因为同一个setNum,不能写在同一语句中。