This seems to be a static intitialization/race condition problem in Qt 4.7.4:
  • Sometimes after I re-compile the problem goes away (this is also probably the cause why adding/removing QtGui has any effect)
  • The problem goes away when I use Qt 4.7.4 compiled without glib
  • It also goes away when I use Qt 4.8.0, which had some QThread race conditions fixed