不想让qDebug() 自动添加\n
时间: 2023-11-22 07:04:12 浏览: 39
你可以使用 qInfo() 代替 qDebug(),并设置输出格式为不自动添加换行符。例如:
```
qSetMessagePattern("[%{type}] %{message}");
qInfo() << "This is a message.";
```
这将输出类似于 "[info] This is a message." 的结果,而不是自动添加换行符的默认输出。
相关问题
qdebug 不自动换行
是的,qDebug 默认情况下不会自动换行。如果你想让它自动换行,可以使用 `qSetMessagePattern` 函数来指定输出格式,例如:
```cpp
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss.zzz} %{message}\n");
```
这个函数会设置输出格式为时间戳和消息,并在每条消息后面加上一个换行符。
qDebug 不自动换行
是的,qDebug 默认情况下不会自动换行。如果你想让它自动换行,可以使用 `qSetMessagePattern` 函数来指定输出格式,例如:
```cpp
qSetMessagePattern("%{time yyyy-MM-dd hh:mm:ss.zzz} %{message}\n");
```
这个函数会设置输出格式为时间戳和消息,并在每条消息后面加上一个换行符。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)