[PyQt] QWidget focusInEvent() ?
B Clowers
clowersb at yahoo.com
Thu May 29 16:23:44 BST 2008
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 accomplish this task?
Thanks
Brian
################################################
import sys
from PyQt4 import QtGui, QtCore
class TestWidget(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300, 300, 250, 150)
self.setWindowTitle('Test Widget')
quit = QtGui.QPushButton('Close', self)
quit.setGeometry(10, 10, 60, 35)
self.connect(quit, QtCore.SIGNAL('clicked()'),
QtGui.qApp, QtCore.SLOT('quit()'))
#Something like the following is what I'd like to do#
self.connect(self.focusInEvent,QtCore.SIGNAL('triggered()'),self.focus_event)
def focus_event(self):
print "This window has focus!"
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
tw = TestWidget()
tw.show()
sys.exit(app.exec_())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080529/e5b145fc/attachment.html
More information about the PyQt
mailing list