如何在 Qt 中禁用某些控制台警告 [英] How to disable certain console warnings in Qt

查看:51
本文介绍了如何在 Qt 中禁用某些控制台警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些绘制事件上,Qt 在控制台输出几个警告:QPainter::begin: Painter already active"

On some paint events, Qt outputs several warnings in the console: "QPainter::begin: Painter already active"

我想禁用此特定警告,因为它使输出窗口变得混乱,而且我不打算修复它.我该怎么做?

I would like to disable this particular warning because it clutters the Output window and I'm not planning to fix it. How can I do that?

推荐答案

唯一的方法是从 Qt 源中删除它并重新编译它们.但是,修复原因会更容易和可靠.

The only way to do it is to remove it from the Qt sources and recompile them. But it would be much easier and reliable to just fix the cause.

P.S. 实际上,如另一个答案中所述,可以安装 msg 处理程序并通过调用 strcmp() 过滤掉该特定消息,但这既丑陋又不太可靠 - 如果该消息在任何未来版本中被更改,它将再次开始出现.

P. S. Actually, as noted in the other answer, it is possible to install an msg handler and filter out that particular message by calling strcmp(), but that's both ugly and not very reliable - if the message is altered in any future version, it will start appearing again.

这篇关于如何在 Qt 中禁用某些控制台警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆