How to disable certain console warnings in Qt

2019-04-13 07:37发布

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 warnings
2条回答
放荡不羁爱自由
2楼-- · 2019-04-13 08:09

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

查看更多
聊天终结者
3楼-- · 2019-04-13 08:15

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.

查看更多
登录 后发表回答