今天需要用到debug,想到還得寫文字,就想偷個懶,制作了兩個宏定義,如下,以后需要的地方直接調用宏定義就好
定義兩個的原因是寫msg默認值時候,會報錯,為了簡便,就定義兩個
#include <QDebug>
#define myDebugMsg(msg) qDebug()<<QString("[Debug] File:%1 Line:%2 Function:%3 Msg:%4").arg(__FILE__).arg(__LINE__).arg(__FUNCTION__).arg(msg)
#define myDebug() qDebug()<<QString("[Debug] File:%1 Line:%2 Function:%3").arg(__FILE__).arg(__LINE__).arg(__FUNCTION__)
使用如下