qDebug()的使用方法

qDebug()的使用方法

qDebug()使用比较简单,步骤:
1、添加头文件
2、使用qDebug()输出
qDebug的输出方式:
1、 将要输出的字符串当做参数传入到函数—按printf()理解
2、 按照流的形式输出—按cout理解
例子:

#include "widget.h"
#include 
#include

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    int x = 123;
    qDebug("x:%d",x);//函数输出方式

    //使用流的方法输出
    int y = 456;
    qDebug() << "y:" << y;//流输出方式

    return a.exec();
}

你可能感兴趣的:(Qt)