本文整理汇总了Python中qtpy.QtWidgets.QApplication.queryKeyboardModifiers方法的典型用法代码示例。如果您正苦于以下问题:Python QApplication.queryKeyboardModifiers方法的具体用法?Python QApplication.queryKeyboardModifiers怎么用?Python QApplication.queryKeyboardModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QApplication
的用法示例。
在下文中一共展示了QApplication.queryKeyboardModifiers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from qtpy.QtWidgets import QApplication [as 别名]
# 或者: from qtpy.QtWidgets.QApplication import queryKeyboardModifiers [as 别名]
def paintEvent(self, event):
"""
Override Qt method.
Painting the scroll flag area
"""
make_flag = self.make_flag_qrect
# Fill the whole painting area
painter = QPainter(self)
painter.fillRect(event.rect(), self.editor.sideareas_color)
# Paint warnings and todos
block = self.editor.document().firstBlock()
for line_number in range(self.editor.document().blockCount()+1):
data = block.userData()
if data:
if data.code_analysis:
# Paint the warnings
color = self.editor.warning_color
for source, code, severity, message in data.code_analysis:
error = severity == DiagnosticSeverity.ERROR
if error:
color = self.editor.error_color
break
self.set_painter(painter, color)
painter.drawRect(make_flag(line_number))
if data.todo:
# Paint the todos
self.set_painter(painter, self.editor.todo_color)
painter.drawRect(make_flag(line_number))
if data.breakpoint:
# Paint the breakpoints
self.set_painter(painter, self.editor.breakpoint_color)
painter.drawRect(make_flag(line_number))
block = block.next()
# Paint the occurrences
if self.editor.occurrences:
self.set_painter(painter, self.editor.occurrence_color)
for line_number in self.editor.occurrences:
painter.drawRect(make_flag(line_number))
# Paint the found results
if self.editor.found_results:
self.set_painter(painter, self.editor.found_results_color)
for line_number in self.editor.found_results:
painter.drawRect(make_flag(line_number))
# Paint the slider range
if not self._unit_testing:
alt = QApplication.queryKeyboardModifiers() & Qt.AltModifier
else:
alt = self._alt_key_is_down
cursor_pos = self.mapFromGlobal(QCursor().pos())
is_over_self = self.rect().contains(cursor_pos)
is_over_editor = self.editor.rect().contains(
self.editor.mapFromGlobal(QCursor().pos()))
# We use QRect.contains instead of QWidget.underMouse method to
# determined if the cursor is over the editor or the flag scrollbar
# because the later gives a wrong result when a mouse button
# is pressed.
if ((is_over_self or (alt and is_over_editor)) and self.slider):
pen_color = QColor(Qt.gray)
pen_color.setAlphaF(.85)
painter.setPen(pen_color)
brush_color = QColor(Qt.gray)
brush_color.setAlphaF(.5)
painter.setBrush(QBrush(brush_color))
painter.drawRect(self.make_slider_range(cursor_pos))
self._range_indicator_is_visible = True
else:
self._range_indicator_is_visible = False