如何禁用 Qt 中的某些控制台警告
在某些绘画事件中,Qt 在控制台中输出几个警告:“QPainter::begin: Painter 已处于活动状态”
我想禁用此特定警告,因为它会使输出窗口变得混乱,而且我不打算修复它。我怎样才能做到这一点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一的方法是将其从 Qt 源代码中删除并重新编译它们。但仅仅解决原因会更容易、更可靠。
PS 实际上,正如另一个答案中所述,可以安装一个消息处理程序并通过调用 strcmp() 过滤掉该特定消息,但这既难看又不太可靠 - 如果该消息在任何未来版本中发生更改,它将再次开始出现。
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. 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 消息
qInstallMessageHandler< /代码>
。您提到的具体消息是
qWarning
消息。You can suppress any Qt message by installing your own message handlers with
qInstallMessageHandler
. The specific message you mentioned is aqWarning
message.