[PyQt] problem with pyqt 4.6
Linos
info at linos.es
Fri Oct 16 15:27:00 BST 2009
i dont know if this is a bug or a change in behaviour but keyPressEvent dont
catch the keyboard events in my QWidget or QDialog subclasses. In the example
added with PyQt 4.4 you can press any key and get his int code printed but with
last snapshot it never prints anything.
----- CODE
# -*- coding: utf-8 -*-
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class TestWidget(QWidget):
def __init__(self, parent):
super(TestWidget, self).__init__()
self.button = QPushButton("test")
layout = QVBoxLayout()
layout.addWidget(self.button)
self.setLayout(layout)
def keyPressEvent(self, event):
print event.key()
def main():
app = QApplication(sys.argv)
widget = TestWidget(None)
widget.show()
return app.exec_()
if __name__ == "__main__":
main()
-----
More information about the PyQt
mailing list