qdebug dump struct 转载

链接处代码段,实测有效
https://blog.51cto.com/u_15246509/2844770

#include <QDebug>
typedef  struct KalmanInfo_t{
        qreal filterValue;  //k-1时刻的滤波值,即是k-1时刻的值
        qreal kalmanGain;   //   Kalamn增益
        qreal A;   // x(n)=A*x(n-1)+u(n),u(n)~N(0,Q)
        qreal H;   // z(n)=H*x(n)+w(n),w(n)~N(0,R)
        qreal Q;   //预测过程噪声偏差的方差
        qreal R;   //测量噪声偏差,(系统搭建好以后,通过测量统计实验获得)
        qreal P;   //估计误差协方差

        friend QDebug operator <<(QDebug out,  KalmanInfo_t *info)
        {
            out << "struct KalmanInfo ["
                << "kalmanGain" <<info->kalmanGain
                << "filterValue" <<info->filterValue
                << "A" << info->A
                << "H" << info->H
                << "Q" << info->Q
                << "R" << info->R
                << "P" << info->P
                << "]";
            return out;
        }
    }  KalmanInfo;

//----------------------------------------------------------------
qDebug()<<"kalmanfilter : "<<kinfo<<endl;
qdebug resault:
kalmanfilter :  struct KalmanInfo [ kalmanGain 0.146107 filterValue -1.60787 A 1 H 1 Q 1e-07 R 4e-06 P 5.84429e-07 ]
上一篇:WinPcap处理脱机的堆文件


下一篇:内存溢出+CPU占用过高:问题排查+解决方案+复盘(超详细分析教程)