我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用PyQt5.QtCore.Qt.AltModifier()。
def _doubleClicked(self, index): model = self.model() if model is None: return data = model.data(index) if isinstance(data, QColor): if QApplication.keyboardModifiers() & Qt.AltModifier: model.setData(index, QColor()) else: dialog = QColorDialog(self) dialog.setCurrentColor(data) dialog.setOption(QColorDialog.ShowAlphaChannel) ret = dialog.exec_() if ret: color = dialog.currentColor() model.setData(index, color) # ------------------- # Convenience methods # -------------------
def key_event_sequence(event): val = event.key() mod = event.modifiers() if mod & Qt.ShiftModifier: val += Qt.SHIFT if mod & Qt.ControlModifier: val += Qt.CTRL if mod & Qt.AltModifier: val += Qt.ALT if mod & Qt.MetaModifier: val += Qt.META return QKeySequence(val)
def translateModifiers(self, state, text): result = 0 if ((state & Qt.ShiftModifier) and (len(text) == 0 or not text[0].isprintable() or text[0].isalpha() or text[0].isspace())): result |= Qt.SHIFT if (state & Qt.ControlModifier): result |= Qt.CTRL if (state & Qt.MetaModifier): result |= Qt.META if (state & Qt.AltModifier): result |= Qt.ALT return result
def eventFilter(self, source, event): """ Add/remove a few keyboard and mouse events. """ if source is self.searchQuery: if event.type() == QEvent.KeyPress: if event.key() == Qt.Key_Return: if event.modifiers() == Qt.ShiftModifier: self.on_arxiv_clicked() return True elif event.modifiers() == Qt.ControlModifier: self.on_msn_clicked() return True elif event.modifiers() == Qt.AltModifier: self.on_zbl_clicked() return True return QMainWindow.eventFilter(self, source, event)
def keyPressEvent(self, event): if event.key() & Qt.Key_Return: if self._mayClearColor and event.modifiers() & Qt.AltModifier: self.setColor(None) else: self.pickColor() else: super(ColorVignette, self).keyPressEvent(event)
def mousePressEvent(self, event): if self._mayClearColor and event.modifiers() & Qt.AltModifier: self.setColor(None) else: super(ColorVignette, self).mousePressEvent(event)
def scaleModifier(): if sys.platform == "darwin": return Qt.AltModifier return Qt.ControlModifier