Le 08/09/10 11:06, [email protected] a écrit :
Hi, Why ' self.plainTextEdit.keyPressEvent(event) ' is into the def ? Like this, that's works : #!/usr/bin/env python # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui class MainGui(object): def setupUi(self, MainWindow): MainWindow.resize(218, 379) self.centralwidget = QtGui.QWidget(MainWindow) self.layout = QtGui.QVBoxLayout(self.centralwidget) self.p_text = QtGui.QPlainTextEdit(self.centralwidget) self.layout.addWidget(self.p_text) MainWindow.setCentralWidget(self.centralwidget) self.p_text.keyPressEvent = self.keyPressEvent def keyPressEvent(self, e): print "event", e if e.key() == QtCore.Qt.Key_Return : print ' return' elif e.key() == QtCore.Qt.Key_Enter : print ' enter' if __name__ == "__main__": import sys app = QtGui.QApplication(sys.argv) MainWindow = QtGui.QMainWindow() ui = MainGui() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_()) |
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
