36 lines
865 B
C++
36 lines
865 B
C++
#include "PrintMsgToQDebug.h"
|
|
#include <QDebug>
|
|
BASECONSTVARIABLEAPI void PrintMsgToQDebug(char* msg)
|
|
{
|
|
qDebug() << QString(msg);
|
|
return ;
|
|
}
|
|
|
|
BASECONSTVARIABLEAPI void PrintfToQDebug(const char* msg)
|
|
{
|
|
qDebug() << QString(msg);
|
|
return;
|
|
}
|
|
|
|
BASECONSTVARIABLEAPI void PrintTipMsgToQDebug(const char* tip, const char* msg)
|
|
{
|
|
qDebug() <<QString(tip)<<"\t:\t" << QString(msg);
|
|
return;
|
|
}
|
|
// 自定义的 printf 风格函数
|
|
BASECONSTVARIABLEAPI void printfinfo(const char* format, ...) {
|
|
char buffer[256]; // 假设最大输出长度为 256 字节
|
|
va_list args;
|
|
|
|
// 使用 va_start 获取可变参数列表
|
|
va_start(args, format);
|
|
|
|
// 使用 vsnprintf 将格式化字符串写入 buffer
|
|
vsnprintf(buffer, sizeof(buffer), format, args);
|
|
|
|
// 结束可变参数列表的使用
|
|
va_end(args);
|
|
|
|
// 将格式化后的字符串转发给 PrintfToQDebug
|
|
PrintfToQDebug(buffer);
|
|
} |