[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] FocusEvent problem with QTabWidget
From:       Philippe Fremy <phil () freehackers ! org>
Date:       2009-03-10 16:45:22
Message-ID: 49B69922.6000004 () freehackers ! org
[Download RAW message or body]

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

["use_focusevent.py" (text/plain)]

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()



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic