由于对于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
}