开发者

How to disable certain console warnings in Qt

On some paint events, Qt outputs several warnings in the con开发者_如何学编程sole: "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?


You can suppress any Qt message by installing your own message handlers with qInstallMessageHandler. The specific message you mentioned is a qWarning message.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜