📜  pyqt5 keypressevent - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:24.199000             🧑  作者: Mango

代码示例1
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent=parent)
        self.setupUi(self)

    def keyPressEvent(self, e):
        if e.key() == Qt.Key_F5:
            self.close()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())