Qt辅助调试release版本代码的函数Msg()

来源:互联网 发布:夜神模拟器mac 编辑:程序博客网 时间:2024/06/12 01:14

由于对于release版本来说,没法在控制台输出信息。弹窗输出就会方便很多。



#include <QString>
#include <QDebug>
#include <QMessageBox>
#include <msg.h>
//template<class T>
void Msg(QString Qstr)
{
#ifdef MSG_DEBUG
    QMessageBox Qmsg;
    Qmsg.setText(Qstr);
    Qmsg.exec();
    qDebug()<<Qstr;
#endif
}



void Msg(QString Qstr, QString file, int line) //参数为__FILE__,__LINE__
{
#ifdef MSG_DEBUG
    QMessageBox Qmsg;
    QString QstrOut;
    QstrOut = Qstr + (QString)("\n") + file + (QString)("\n") + QString::number(line);
    Qmsg.setText(QstrOut);
    Qmsg.exec();
    qDebug()<<Qstr;
#endif
}

0 0