Qt 应用程序中显示的错误 - 如何不在 Release 中显示它们 [英] Errors showing in Qt application - how to not display them in Release

查看:48
本文介绍了Qt 应用程序中显示的错误 - 如何不在 Release 中显示它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个 Qt 项目给出了许多错误 - 我实际上并没有考虑我认为的错误:

A Qt project gives a number of errors - that I do not actually consider errors I think:

一些例子:

Fontconfig error: "/etc/fonts/conf.d/65-khmer.conf", line 32: out of memory
  // ? 
QGraphicsItem::ungrabMouse: not a mouse grabber 
  // i think happens when the mouse grab didn't quite happen, user moved too fast...

其他一些

第一个似乎在这里有答案https://askubuntu.com/questions/421891/fontconfig-error-out-of-memory

the first one seems it has an answer here https://askubuntu.com/questions/421891/fontconfig-error-out-of-memory

所以我不能通过软件修复它,用户必须修复它......因为它依赖于系统......

So I cannot fix it through software, the user must fix it... since it is system dependent...

即使是内置版本,这些错误仍会显示在命令行上...由于它们不会导致应用程序运行异常,我认为用户不应该看到它们.

Even built in release, these errors will still show up on command line... Since they do not cause the application to behave abnormally, I don't think the user should see them.

如何在不显示这些错误的情况下构建/部署应用程序?

How can I build/deploy the application without these errors showing ?

理想情况下,部署的应用程序中当然不会出现错误,但我不知道我能对这些类型的错误做些什么......

ideally of course there would be no errors in a deployed application, but I don't know what I can do about those types of errors...

推荐答案

可以在事后使用

freopen("/dev/null", "w", stderr);

在任何其他代码运行之前把它放在你的 main 中,你应该很好.请记住,这可能需要在 Windows 上进行更多工作.

Just place this in your main before any other code runs and you should be good. Keep in mind that this might need more work on Windows.

如果错误消息是通过 Qt 消息基础结构(qDebug 等)发布的,您可以通过函数 qInstallMsgHandler.

If the error message is posted through the Qt Message infrastructure (qDebug etc.) you can set a new message handler through the function qInstallMsgHandler.

这篇关于Qt 应用程序中显示的错误 - 如何不在 Release 中显示它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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