467,907 Members | 1,613 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

PyQt4 signal slot method

Hi ,
I am a newbie to python and I am trying to send a signal to my application using a thread.
Here's my code:
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import *
class MyThread(QtCore.QThread,QtCore.QObject):

def __init__(self, parent):

QtCore.QThread.__init__(self, parent)
QtCore.QObject.__init__(self,parent)
def run(self):
a=Emit()
#self.connect(self, QtCore.SIGNAL('closeEmitApp()'), self.parent(),QtCore.SLOT('close()') )
while self.isRunning():
print "We are running"
self.sleep(10)

self.emit(QtCore.SIGNAL('closeEmitApp()'))

class Emit(QtGui.QWidget,MyThread):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
# a = MyThread(app)
self.setWindowTitle('emit')
self.resize(250, 150)
print 'asdf'
self.connect(self, QtCore.SIGNAL('closeEmitApp()'), QtCore.SLOT('close()'),Qt.QueuedConnection )
#a.start()
def mousePressEvent(self,event):
self.emit(QtCore.SIGNAL('closeEmitApp()'))
mythread.quit()
app = QtGui.QApplication(sys.argv)
qb = Emit()
qb.show()
mythread = MyThread(app)
mythread.start()
sys.exit(app.exec_())

I am unable to figure out why the thread is unable to send the signal to the Emit class.
Thank you in advance
-kunal
Jun 27 '08 #1
  • viewed: 3151
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Skink | last post: by
2 posts views Thread by Glen | last post: by
2 posts views Thread by Pradnyesh Sawant | last post: by
reply views Thread by Pradnyesh Sawant | last post: by
2 posts views Thread by jiang.haiyun | last post: by
2 posts views Thread by Bighead | last post: by
3 posts views Thread by ff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.