我编写了一个带有大量代码库的应用程序(大约30k行),有时候,当它得到cpu密集时,shell输出会填充这样的东西:
QPainter::scale: Painter not active
QPainter::setCompositionMode: Painter not active
QPainter::scale: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setPen: Painter not active
QPainter::end: Painter not active, aborted
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::translate: Painter not active
QPainter::scale: Painter not active
QPainter::setCompositionMode: Painter not active
QPainter::scale: Painter not active
永远持续下去。问题是我在许多不同的小部件中有数十个QPainter实例,所以我无法追踪它。有没有办法追踪这些消息?我在不同的项目中多次遇到过这个问题。我已经尝试将此添加到我的项目中
QT_MESSAGE_PATTERN="[%{type}] %{appname} (%{file}:%{line}) - %{message}"
正如Qt文档中所建议的那样,但之后我再也没有得到任何调试消息了。完全卡住了!谢谢!
答案 0 :(得分:0)
一个解决方案:拥有Qt的自建调试版本,然后在源代码中找到这些消息,并在那里设置断点。
最有可能的是你在绘制事件或其他线程之外尝试一个小部件。或者您正在绘制一个paint事件中的事件循环。