Integrating twisted into existing pyqt GUI application
<p>I am trying to add twisted to my already existing app. According to <a href="https://pypi.python.org/pypi/qt4reactor/1.6" rel="nofollow">this</a> and other sources, I should import qt4reactor. When I try:</p>

<pre><code>app = QApplication(sys.argv)
from twisted.application import reactors
reactors.installReactor('pyqt4')
</code></pre>

<p>(I also tried:)</p>

<pre><code>from twisted.internet import qt4reactor 
</code></pre>

<p>I get twisted.application.reactors.NoSuchReactor: 'pyqt4'. I can download and install qt4reactor directly, but then I can't install it after instantiating QApplication?</p>

<p>Also, since I am adding on twisted, the documentation states that I should use reactor.runReturn() instead of reactor.run(). </p>

<pre><code>from twisted.internet import reactor, protocol
reactor.listenTCP(8001, tcpFactory())
reactor.runReturn()
</code></pre>

<p>When I try this, I get AttributeError: 'SelectReactor' object has no attribute 'runReturn'. Is this because I am unable to install qt4reactor after instantiating QApplication? </p>

<p>Now qt4reactor is separate from Twisted and located <a href="https://github.com/ghtdak/qtreactor" rel="nofollow">here</a></p>

<p>So you need to install it first, then try:</p>

<pre><code>from twisted.application import reactors
reactors.installReactor('pyqt4')
</code></pre>

<p>or</p>

<pre><code>from qtreactor import pyqt4reactor
pyqt4reactor.install()
</code></pre>

python pyqt4 twisted