Python PyQt5.QtCore.Qt 模块,Key_Minus() 实例源码
我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Key_Minus()。
def set_up_keyboard_numbers_keys(self):
row_1 = [Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_4, Qt.Key_5, Qt.Key_6,
Qt.Key_7, Qt.Key_8, Qt.Key_9, Qt.Key_0, Qt.Key_Backspace]
row_2 = [Qt.Key_Minus, Qt.Key_Slash, Qt.Key_Colon, Qt.Key_Semicolon,
Qt.Key_ParenLeft, Qt.Key_ParenRight, Qt.Key_Dollar,
Qt.Key_Ampersand, Qt.Key_At, Qt.Key_Return]
row_3 = [Qt.Key_Aring, Qt.Key_Period, Qt.Key_Comma, Qt.Key_Question,
Qt.Key_Exclam, Qt.Key_QuoteLeft, Qt.Key_QuoteDbl,
Qt.Key_Aring]
row_4 = [Qt.Key_Aring, Qt.Key_Space, Qt.Key_Aring, Qt.Key_Aring]
self.keyboard_numbers_keys = [row_1, row_2, row_3, row_4]
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape and self.isFullScreen():
self.showNormal()
if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_Q:
self.close()
sys.exit()
if event.key() == Qt.Key_Space:
if self.player.player.state() == self.player.player.PlayingState:
self.player.pause()
elif self.player.player.state() == self.player.player.StoppedState or self.player.player.PausedState:
self.player.play()
if event.key() == Qt.Key_Plus:
self.player.setVolume(self.player.volume() + 5)
if event.key() == Qt.Key_Minus:
self.player.setVolume(self.player.volume() - 5)
if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_M:
self.player.setMuted(not self.player.isMuted())
if event.key() == Qt.Key_Right:
self.player.player.setPosition(self.player.player.position() + 10000)
if event.key() == Qt.Key_Left:
self.player.player.setPosition(self.player.player.position() - 10000)
if event.key() == Qt.Key_Up:
self.player.player.setPosition(self.player.player.position() + 60000)
if event.key() == Qt.Key_Down:
self.player.player.setPosition(self.player.player.position() - 60000)
super().keyPressEvent(event)
def createActions(self):
self.cell_sumAction = QAction("Sum", self)
self.cell_sumAction.triggered.connect(self.actionSum)
self.cell_addAction = QAction("&Add", self)
self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
self.cell_addAction.triggered.connect(self.actionAdd)
self.cell_subAction = QAction("&Subtract", self)
self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
self.cell_subAction.triggered.connect(self.actionSubtract)
self.cell_mulAction = QAction("&Multiply", self)
self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
self.cell_mulAction.triggered.connect(self.actionMultiply)
self.cell_divAction = QAction("&Divide", self)
self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
self.cell_divAction.triggered.connect(self.actionDivide)
self.fontAction = QAction("Font...", self)
self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
self.fontAction.triggered.connect(self.selectFont)
self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
self.colorAction.triggered.connect(self.selectColor)
self.clearAction = QAction("Clear", self)
self.clearAction.setShortcut(Qt.Key_Delete)
self.clearAction.triggered.connect(self.clear)
self.aboutSpreadSheet = QAction("About Spreadsheet", self)
self.aboutSpreadSheet.triggered.connect(self.showAbout)
self.exitAction = QAction("E&xit", self)
self.exitAction.setShortcut(QKeySequence.Quit)
self.exitAction.triggered.connect(QApplication.instance().quit)
self.printAction = QAction("&Print", self)
self.printAction.setShortcut(QKeySequence.Print)
self.printAction.triggered.connect(self.print_)
self.firstSeparator = QAction(self)
self.firstSeparator.setSeparator(True)
self.secondSeparator = QAction(self)
self.secondSeparator.setSeparator(True)
def createActions(self):
self.cell_sumAction = QAction("Sum", self)
self.cell_sumAction.triggered.connect(self.actionSum)
self.cell_addAction = QAction("&Add", self)
self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
self.cell_addAction.triggered.connect(self.actionAdd)
self.cell_subAction = QAction("&Subtract", self)
self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
self.cell_subAction.triggered.connect(self.actionSubtract)
self.cell_mulAction = QAction("&Multiply", self)
self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
self.cell_mulAction.triggered.connect(self.actionMultiply)
self.cell_divAction = QAction("&Divide", self)
self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
self.cell_divAction.triggered.connect(self.actionDivide)
self.fontAction = QAction("Font...", self)
self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
self.fontAction.triggered.connect(self.selectFont)
self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
self.colorAction.triggered.connect(self.selectColor)
self.clearAction = QAction("Clear", self)
self.clearAction.setShortcut(Qt.Key_Delete)
self.clearAction.triggered.connect(self.clear)
self.aboutSpreadSheet = QAction("About Spreadsheet", self)
self.aboutSpreadSheet.triggered.connect(self.showAbout)
self.exitAction = QAction("E&xit", self)
self.exitAction.setShortcut(QKeySequence.Quit)
self.exitAction.triggered.connect(QApplication.instance().quit)
self.printAction = QAction("&Print", self)
self.printAction.setShortcut(QKeySequence.Print)
self.printAction.triggered.connect(self.print_)
self.firstSeparator = QAction(self)
self.firstSeparator.setSeparator(True)
self.secondSeparator = QAction(self)
self.secondSeparator.setSeparator(True)
def createActions(self):
self.cell_sumAction = QAction("Sum", self)
self.cell_sumAction.triggered.connect(self.actionSum)
self.cell_addAction = QAction("&Add", self)
self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
self.cell_addAction.triggered.connect(self.actionAdd)
self.cell_subAction = QAction("&Subtract", self)
self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
self.cell_subAction.triggered.connect(self.actionSubtract)
self.cell_mulAction = QAction("&Multiply", self)
self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
self.cell_mulAction.triggered.connect(self.actionMultiply)
self.cell_divAction = QAction("&Divide", self)
self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
self.cell_divAction.triggered.connect(self.actionDivide)
self.fontAction = QAction("Font...", self)
self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
self.fontAction.triggered.connect(self.selectFont)
self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
self.colorAction.triggered.connect(self.selectColor)
self.clearAction = QAction("Clear", self)
self.clearAction.setShortcut(Qt.Key_Delete)
self.clearAction.triggered.connect(self.clear)
self.aboutSpreadSheet = QAction("About Spreadsheet", self)
self.aboutSpreadSheet.triggered.connect(self.showAbout)
self.exitAction = QAction("E&xit", self)
self.exitAction.setShortcut(QKeySequence.Quit)
self.exitAction.triggered.connect(QApplication.instance().quit)
self.printAction = QAction("&Print", self)
self.printAction.setShortcut(QKeySequence.Print)
self.printAction.triggered.connect(self.print_)
self.firstSeparator = QAction(self)
self.firstSeparator.setSeparator(True)
self.secondSeparator = QAction(self)
self.secondSeparator.setSeparator(True)