How to disable certain console warnings in Qt

一笑奈何 提交于 2020-01-01 17:03:45

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4791838/how-to-disable-certain-console-warnings-in-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!