我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Key_Plus()。
def set_up_keyboard_symbols_keys(self): row_1 = [Qt.Key_BracketLeft, Qt.Key_BracketRight, Qt.Key_BraceLeft, Qt.Key_BraceRight, Qt.Key_Aring, Qt.Key_Percent, Qt.Key_Dead_Circumflex, Qt.Key_Asterisk, Qt.Key_Plus, Qt.Key_Equal, Qt.Key_Backspace] row_2 = [Qt.Key_Underscore, Qt.Key_Backslash, Qt.Key_Aring, Qt.Key_Dead_Tilde, Qt.Key_Less, Qt.Key_Greater, Qt.Key_Aring, Qt.Key_Aring, Qt.Key_Aring, 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_symbols_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)