AnimatedToolTipEventFilter
Qt Base Class: QObject
Signature: QObject(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None
Base classes
Name |
Children |
Inherits |
BaseEventFilter prettyqt.eventfilters.baseeventfilter
|
|
|
⋔ Inheritance diagram
graph TD
1473367052096["eventfilters.AnimatedToolTipEventFilter"]
1473367044288["eventfilters.BaseEventFilter"]
1473299782816["core.Object"]
1473299815024["core.ObjectMixin"]
140713234304496["builtins.object"]
1473288842240["QtCore.QObject"]
1473291690208["Shiboken.Object"]
1473367044288 --> 1473367052096
1473299782816 --> 1473367044288
1473299815024 --> 1473299782816
140713234304496 --> 1473299815024
1473288842240 --> 1473299782816
1473291690208 --> 1473288842240
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: BaseEventFilter
Source code in prettyqt\eventfilters\animatedtooltipeventfilter.py
| class AnimatedToolTipEventFilter(eventfilters.BaseEventFilter):
ID = "animated_tooltip"
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.tool_tip = widgets.Label()
self.tool_tip.set_flags(frameless=True, tooltip=True)
self.tool_tip.set_attributes(
transparent_for_mouse_events=True,
no_system_background=True,
translucent_background=True,
)
self.tool_tip.hide()
self.slide_anim = animations.SlideAnimation(self.tool_tip, duration=1000)
self.slide_anim.apply_to(self.tool_tip)
self.fade_anim = animations.FadeInAnimation(duration=1000)
self.fade_anim.apply_to(self.tool_tip)
self.animation = self.slide_anim | self.fade_anim
def eventFilter(self, obj: widgets.QWidget, event: core.QEvent) -> bool:
match event.type():
case core.QEvent.Type.Enter:
# self.tool_tip.adjustSize()
self.tool_tip.setText(obj.toolTip())
self.tool_tip.show()
position = "bottom"
distance = 100
center = obj.rect().center()
match position:
case "top":
center.setY(obj.rect().bottom())
delta = core.Point(0, distance)
case "bottom":
center.setY(obj.rect().top())
delta = core.Point(0, -distance)
case "left":
center.setX(obj.rect().right())
delta = core.Point(distance, 0)
case "right":
center.setX(obj.rect().left())
delta = core.Point(-distance, 0)
center = obj.mapToGlobal(center)
self.slide_anim.set_start_value(center + delta)
self.slide_anim.set_end_value(center)
self.animation.start_animation()
case core.QEvent.Type.Leave:
self.tool_tip.hide()
self.animation.stop()
case core.QEvent.Type.ToolTip:
return True
return super().eventFilter(obj, event)
|
⌗ Property table
Qt Property |
Type |
Doc |
objectName |
QString |
|