给点颜色打印输出

2020-05-26 00:26:19 浏览数 (1)

❝调试打印有点颜色输出,让编程更美好! ❞

  不多说直接上代码:

代码语言:javascript复制
#include <QDebug>

#define NONE         "33[0m"
#define DARK         "33[30m"
#define RED          "33[31m"
#define GREEN        "33[32m"
#define YELLOW       "33[33m"
#define BLUE         "33[34m"
#define PURPLE       "33[35m"
#define CYAN         "33[36m"
#define WHITE        "33[37m"

int main(int, char **)
{
    qDebug() << "--------------------------";
    qDebug() << DARK   << "Dark";
    qDebug() << RED    << "Red";
    qDebug() << GREEN  << "Green";
    qDebug() << YELLOW << "Yellow";
    qDebug() << BLUE   << "Blue";
    qDebug() << PURPLE << "Purple";
    qDebug() << CYAN   << "Cyan";
    qDebug() << WHITE  << "White";
    qDebug() << NONE   << "None: Reset Default Color";
    qDebug() << "--------------------------";
    return 0;
}

  输出:

0 人点赞