且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调试在Qt Creator中断言

更新时间:2023-10-27 08:59:16

可以为Qt发出的消息/警告安装处理程序,并自己处理它们。请参阅 qInstallMsgHandler 的文档> 和他们给的例子。应该很容易在自定义消息处理程序中插入断点(或者确实,在此时自己断言)。一个小的缺点是,你会比在错误实际发生的位置更进一步,但它是一个简单的事情,只是加快堆栈,直到你在正确的框架。

You can install a handler for the messages/warnings that Qt emits, and do your own processing of them. See the documentation for qInstallMsgHandler and the example they give there. It should be easy to insert a break in a custom message handler (or indeed, just assert on your own at that point). The one small drawback is that you'll be a bit further on down the stack than where the error actually occurred, but it is a simple matter to just step up the stack until you are at the proper frame.