开发者

Tips on debugging PyQt

I've got a PyQt开发者_运维百科4 project with a very weird error, under certain circumstances the main thread simply dies and I have no idea why.

  • No exception reported or shown, I've tried wrapping a try - except around app.exec_() and nothing.
  • sys.exit() is not called

Does anybody have any tips, is there a tool to see what signals/messages are passed around inside Qt or something else?


It is likely that the application is crashing in Qt. Try running the program with gdb.

gdb --args python myprog.py

When the program crashes, this should give you a backtrace that may shed some light on what is going on.

Note that having debug symbols available for Qt will make the backtrace more useful. On Ubuntu or Debian systems, the libqt4-dbg package can be installed to make these debug symbols available.


Reading the backtrace with gdb is the first step, as suggested (after the program crashes, type'backtrace' in gdb). In many cases, though, this will not lead to an obvious solution.

Here's a collection of things to look out for that cause crashes: What are good practices for avoiding crashes / hangs in PyQt?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜