由于对于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
}
本文介绍如何在C++控制台应用中利用QMessageBox进行信息输出,包括基本用法和带文件名和行号的详细信息展示。

6827

被折叠的 条评论
为什么被折叠?



