QtToolTip#
Custom tooltip bubbles with tail positions, optional images, and styled content.
Screenshot#

Example#
Source: examples/qt_tooltip.py
"""QtToolTip example."""
from qtpy.QtCore import QSize
from qtpy.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget
from qtextra.config import THEMES
from qtextra.helpers import make_qta_icon
from qtextra.widgets.qt_tooltip import QtToolTip, TipPosition
def create_popout():
"""Create a popout."""
tail_position = TipPosition.BOTTOM
QtToolTip.init(
title=f"Displaying ToolTip with {tail_position}",
content="Here you can add custom text that will be displayed below the title.",
parent=widget,
tail_position=tail_position,
target=button,
is_closable=True,
image=make_qta_icon("home").pixmap(QSize(32, 32))
if tail_position in [TipPosition.LEFT, TipPosition.RIGHT]
else None,
)
app = QApplication([])
widget = QWidget()
widget.setMinimumSize(600, 300)
THEMES.apply(widget)
layout = QVBoxLayout()
widget.setLayout(layout)
layout.addWidget(button := QPushButton("Press me to see tooltip"))
button.clicked.connect(create_popout)
widget.show()
create_popout()
app.exec_()
API#
Qt Class#
Methods#
tool tip.
view
property
#
addWidget(widget: QWidget, stretch=0, align=Qt.AlignmentFlag.AlignLeft)
#
Add widget to tool tip.
init(target: QWidget, title: str, content: str, icon: ty.Union[QIcon, str] | None = None, image: ty.Union[str, QPixmap, QImage] | None = None, is_closable: bool = True, duration: int = 1000, tail_position=TipPosition.BOTTOM, parent=None, delete_on_close=True)
classmethod
#
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
QWidget
|
the target widget to show tip |
required |
title
|
str
|
the title of tool tip |
required |
content
|
str
|
the content of tool tip |
required |
icon
|
Union[QIcon, str] | None
|
the icon of tool tip |
None
|
image
|
Union[str, QPixmap, QImage] | None
|
the image of tool tip |
None
|
is_closable
|
bool
|
whether to show the close button |
True
|
duration
|
int
|
the time for tool tip to display in milliseconds. If duration is less than zero, tool tip will never disappear. |
1000
|
parent
|
parent widget |
None
|
|
tail_position
|
the position of bubble tail |
BOTTOM
|
|
delete_on_close
|
whether delete flyout automatically when flyout is closed |
True
|
setShadowEffect(blurRadius=35, offset=(0, 8))
#
Add shadow to dialog.
setView(view)
#
Methods#
tool tip tail position.