本文整理汇总了Python中PyQt5.QtGui.QGuiApplication.keyboardModifiers方法的典型用法代码示例。如果您正苦于以下问题:Python QGuiApplication.keyboardModifiers方法的具体用法?Python QGuiApplication.keyboardModifiers怎么用?Python QGuiApplication.keyboardModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QGuiApplication
的用法示例。
在下文中一共展示了QGuiApplication.keyboardModifiers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleCursorPositionChanged
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import keyboardModifiers [as 别名]
def handleCursorPositionChanged(self):
cursor = self.textCursor()
# update block format toolbar
blockFmt = cursor.blockFormat()
blockStyle = blockFmt.property(QTextFormat.UserProperty)
self.updateBlockFormat.emit(blockStyle)
# update text format toolbar
charFmt = cursor.charFormat() # get the QTextCharFormat at the current cursor position
charStyle = charFmt.property(QTextFormat.UserProperty)
self.updateCharFormat.emit(charStyle)
# open/close URL editor for external links
if charStyle and charStyle[0] == 'link':
if not (QGuiApplication.keyboardModifiers() & Qt.ControlModifier):
url = charFmt.anchorHref()
# get global cursor position
pos = self.cursorRect()
pos = pos.bottomLeft()
pos = self.viewport().mapToGlobal(pos)
self.l.move(pos)
self.l.setUrl(url)
self.l.show()
else:
self.l.hide()
示例2: _template_clicked
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import keyboardModifiers [as 别名]
def _template_clicked(self, index, template):
"""
Set item's template to selected.
If Ctrl key pressed - find next item without the template and focus on it.
"""
self.visible_items[index].template = template
buttons = self.findChildren(QRadioButton, name="menu_button")
buttons[index].setText(self._get_button_name(self.visible_items[index]))
if QGuiApplication.keyboardModifiers() != Qt.ControlModifier:
return
for i in range(len(self.visible_items)):
ind = (i + index) % len(self.visible_items)
if not self.visible_items[ind].template:
self.templates_layout.setCurrentIndex(ind)
buttons[ind].setChecked(True)
buttons[index].setChecked(False)
return
示例3: wheelEvent
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import keyboardModifiers [as 别名]
def wheelEvent(self, event):
modifiers = QGuiApplication.keyboardModifiers()
if modifiers == Qt.ControlModifier:
font = globalSettings.editorFont
size = font.pointSize()
scroll = event.angleDelta().y()
if scroll > 0:
size += 1
elif scroll < 0:
size -= 1
else:
return
font.setPointSize(size)
self.parent.setEditorFont(font)
else:
QTextEdit.wheelEvent(self, event)
if event.angleDelta().y() < 0:
scrollBarLimit = self.verticalScrollBar().maximum()
else:
scrollBarLimit = self.verticalScrollBar().minimum()
if self.verticalScrollBar().value() == scrollBarLimit:
self.scrollLimitReached.emit(event)
示例4: keyPressEvent
# 需要导入模块: from PyQt5.QtGui import QGuiApplication [as 别名]
# 或者: from PyQt5.QtGui.QGuiApplication import keyboardModifiers [as 别名]
def keyPressEvent(self, event):
if QGuiApplication.keyboardModifiers() != Qt.ControlModifier:
return
if event.key() == Qt.Key_Return:
self.action_btn_function(event=None)