<table cellspacing='0' cellpadding='0' border='0' background='none' style='font-family:arial;font-size:10pt;color:rgb(51, 51, 51);background-color:rgb(255, 255, 255);width:100%;'><tr><td valign='top' style='font: inherit;'><span style="font-family: monospace;">I have what would seem to be a fairly small problem. My application has a main window that currently has the ability to spawn a number of Non-Modal QWidgets in their own respective windows. I need to emit or catch a signal that is produced whenever a particular QWidget in its own window gets the focus. After looking at the documentation I can't seem to find a particular signal that is emitted. Does anyone have an idea how to </span>accomplish this task?<br><br>Thanks<br><br>Brian<br>################################################<br><br>import sys<br>from PyQt4 import QtGui, QtCore<br><br><br>class TestWidget(QtGui.QWidget):<br> def __init__(self,
parent=None):<br> QtGui.QWidget.__init__(self, parent)<br><br> self.setGeometry(300, 300, 250, 150)<br> self.setWindowTitle('Test Widget')<br><br> quit = QtGui.QPushButton('Close', self)<br> quit.setGeometry(10, 10, 60, 35)<br><br> self.connect(quit, QtCore.SIGNAL('clicked()'),<br> QtGui.qApp, QtCore.SLOT('quit()'))<br> <br> #Something like the following is what I'd like to do#<br> self.connect(self.focusInEvent,QtCore.SIGNAL('triggered()'),self.focus_event)<br> <br> def
focus_event(self):<br> print "This window has focus!"<br> <br> <br>if __name__ == "__main__":<br> <br> app = QtGui.QApplication(sys.argv)<br> tw = TestWidget()<br> tw.show()<br> sys.exit(app.exec_())<br></td></tr></table><br>