QKeySequenceEdit 的继承图 :
QKeySequenceEdit 的描述 :
QKeySequenceEdit 的继承 :
它是继承自QWidget 的
from PyQt5.Qt import * #刚开始学习可以这样一下导入import sysclass Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("QKeySequenceEdit 控件的学习") self.resize(400,400) self.set_ui() def set_ui(self): ############################创建QKeySequenceEdit 控件来采集快捷键############################### keySequenceEdit = QKeySequenceEdit(self) ############################创建QKeySequenceEdit 控件来采集快捷键###############################if __name__ == '__main__': app =QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
QKeySequenceEdit 的功能作用:
补充:QKeySequence
键位序列的分类,这里主要分为两类 :一个是标准的键位序列,另一个是自定义键位序列!
具体标准键可查看:
下面继续说QKeySequenceEdit 的功能作用:
from PyQt5.Qt import * #刚开始学习可以这样一下导入import sysclass Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("QKeySequenceEdit 控件的学习") self.resize(400,400) self.set_ui() def set_ui(self): ############################创建QKeySequenceEdit 控件来采集快捷键############################### keySequenceEdit = QKeySequenceEdit(self) keySequence = QKeySequence("Ctrl+C") #2 keySequence = QKeySequence(QKeySequence.Copy) #3 keySequence = QKeySequence(Qt.CTRL+Qt.Key_C,Qt.CTRL+Qt.Key_C) keySequenceEdit.setKeySequence(keySequence) ############################获取QKeySequenceEdit 中的快捷键############################### btn = QPushButton(self ) btn.setText("按钮") btn.move(0,300) # btn.clicked.connect(lambda :print(keySequenceEdit.keySequence())) ############################转化为可读字符串 以及统计 快捷键个数 ############################### btn.clicked.connect(lambda :print(keySequenceEdit.keySequence().toString())) btn.clicked.connect(lambda :print(keySequenceEdit.keySequence().count())) #清除 # keySequenceEdit.clear() ############################转化为可读字符串 以及统计 快捷键个数 ############################### ############################获取QKeySequenceEdit 中的快捷键############################### ############################创建QKeySequenceEdit 控件来采集快捷键###############################if __name__ == '__main__': app =QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
QKeySequenceEdit 的信号:
from PyQt5.Qt import * #刚开始学习可以这样一下导入import sysclass Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("QKeySequenceEdit 控件的学习") self.resize(400,400) self.set_ui() def set_ui(self): ############################创建QKeySequenceEdit 控件来采集快捷键############################### keySequenceEdit = QKeySequenceEdit(self) keySequence = QKeySequence("Ctrl+C") #2 keySequence = QKeySequence(QKeySequence.Copy) #3 keySequence = QKeySequence(Qt.CTRL+Qt.Key_C,Qt.CTRL+Qt.Key_C) keySequenceEdit.setKeySequence(keySequence) keySequenceEdit.editingFinished.connect(lambda :print("结束编辑")) keySequenceEdit.keySequenceChanged.connect(lambda arg:print("键位序列发生改变",arg.toString())) ############################获取QKeySequenceEdit 中的快捷键############################### btn = QPushButton(self ) btn.setText("按钮") btn.move(0,300)if __name__ == '__main__': app =QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())
总结:
至此,所有的文本输入控件就说完了,下面是另一种:通过步长调节(QAbstractSpinBox )(键盘+鼠标)