def event(self, event): if event.type() == QEvent.ToolTip: cursor = self.cursorForPosition(event.pos()) cursor.select(QTextCursor.BlockUnderCursor) if cursor.selectedText(): for dp, np in XmlHighlighter.DEPRECATED_PARAMETER.items(): if 'name="%s"' % dp in cursor.selectedText(): QToolTip.showText(event.globalPos(), ' %s is deprecated, use %s' % (dp, np)) else: QToolTip.hideText() return True return QTextEdit.event(self, event)
def hoverLeaveEvent(self, event): QToolTip.hideText()
def hoverEnterEvent(self, event): QToolTip.showText(event.screenPos(), self.label)