def must_use_qt(headless=True):
 global gui_thread
 ensure_app(headless=headless)
 if (gui_thread is None):
  gui_thread = QThread.currentThread()
 if (gui_thread is not QThread.currentThread()):
  raise RuntimeError('Cannot use Qt in non GUI thread')

def must_use_qt ( headless = True ) : global gui_thread ensure_app ( headless = headless ) if ( gui_thread is None ) : gui_thread = QThread . currentThread ( ) if ( gui_thread is not QThread . currentThread ( ) ) : raise RuntimeError ( 'Cannot use Qt in non GUI thread' )
this function should be called if you want to use qt for some non-gui task like rendering html/svg or using a headless browser .