From pykde Tue Mar 10 16:45:22 2009 From: Philippe Fremy Date: Tue, 10 Mar 2009 16:45:22 +0000 To: pykde Subject: [PyQt] FocusEvent problem with QTabWidget Message-Id: <49B69922.6000004 () freehackers ! org> X-MARC-Message: https://marc.info/?l=pykde&m=123670404832437 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--------------060107090104070905010003" This is a multi-part message in MIME format. --------------060107090104070905010003 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, I am trying to catch focus events on my main widget, which happens to be a QTabWidget. It does not work if the widget is a QTabWidget but works for a regular QWidget. See the attached program, where you can choose the base class. I don't think I'm doing something wrong, so it's either a PyQt bug or Qt bug. Any confirmation ? cheers, Philippe --------------060107090104070905010003 Content-Type: text/plain; name="use_focusevent.py" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="use_focusevent.py" from PyQt4 import QtGui, QtCore # parentClass = QtGui.QWidget # parentClass = QtGui.QTabWidget parentClass = QtGui.QTextEdit class MyWidget( parentClass ): def __init__(self, *args ): parentClass.__init__( self, *args ) print 'old focus policy: ', self.focusPolicy() self.setFocusPolicy( QtCore.Qt.TabFocus ) print 'new focus policy: ', self.focusPolicy() def focusInEvent( self, focusEvent ): print 'focusInEvent' parentClass.focusInEvent( self, focusEvent ) def focusOutEvent( self, focusEvent ): print 'focusOutEvent' parentClass.focusInEvent( self, focusEvent ) def main(): app = QtGui.QApplication([]) w = MyWidget() w.setFocus() w.show() app.exec_() if __name__ == '__main__': main() --------------060107090104070905010003 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt --------------060107090104070905010003--