QToolTipclass provides tool tips (balloon help) for any widget. 更多 …
The tip is a short piece of text reminding the user of the widget’s function. It is drawn immediately below the given position in a distinctive black-on-yellow color combination. The tip can be any
rich textformatted string.Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with
<p style='white-space:pre'>.The simplest and most common way to set a widget’s tool tip is by calling its
setToolTip()函数。It is also possible to show different tool tips for different regions of a widget, by using a
QHelpEventof typeToolTip. Intercept the help event in your widget’sevent()function and callshowText()with the text you want to display. The Tooltips example illustrates this technique.If you are calling
hideText(),或showText()with an empty string, as a result of aToolTip-event you should also callignore()on the event, to signal that you don’t want to start any tooltip specific modes.Note that, if you want to show tooltips in an item view, the model/view architecture provides functionality to set an item’s tool tip; e.g., the
setToolTip()function. However, if you want to provide custom tool tips in an item view, you must intercept the help event in theviewportEvent()function and handle it yourself.The default tool tip color and font can be customized with
setPalette()andsetFont(). When a tooltip is currently on display,isVisible()返回trueandtext()the currently visible text.注意
Tool tips use the inactive color group of
QPalette, because tool tips are not active windows.
PySide2.QtWidgets.QToolTip.
font
(
)
¶
QFont
Returns the font used to render tooltips.
另请参阅
PySide2.QtWidgets.QToolTip.
hideText
(
)
¶
Hides the tool tip. This is the same as calling
showText()
with an empty string.
另请参阅
PySide2.QtWidgets.QToolTip.
isVisible
(
)
¶
bool
返回
true
if this tooltip is currently shown.
另请参阅
PySide2.QtWidgets.QToolTip.
palette
(
)
¶
QPalette
Returns the palette used to render tooltips.
注意
Tool tips use the inactive color group of
QPalette
, because tool tips are not active windows.
另请参阅
PySide2.QtWidgets.QToolTip.
setFont
(
arg__1
)
¶
arg__1
–
QFont
设置
font
used to render tooltips.
另请参阅
PySide2.QtWidgets.QToolTip.
setPalette
(
arg__1
)
¶
arg__1
–
QPalette
设置
palette
used to render tooltips.
注意
Tool tips use the inactive color group of
QPalette
, because tool tips are not active windows.
另请参阅
PySide2.QtWidgets.QToolTip.
showText
(
pos
,
text
[
,
w=None
]
)
¶
pos
–
QPoint
text – unicode
w
–
QWidget
这是重载函数。
This is analogous to calling
showText
(
pos
,
text
,
w
, QRect())
PySide2.QtWidgets.QToolTip.
showText
(
pos
,
text
,
w
,
rect
)
¶
pos
–
QPoint
text – unicode
w
–
QWidget
rect
–
QRect
Shows
text
as a tool tip, with the global position
pos
as the point of interest. The tool tip will be shown with a platform specific offset from this point of interest.
If you specify a non-empty rect the tip will be hidden as soon as you move your cursor out of this area.
rect
is in the coordinates of the widget you specify with
w
。若
rect
is not empty you must specify a widget. Otherwise this argument can be
None
but it is used to determine the appropriate screen on multi-head systems.
若
text
is empty the tool tip is hidden. If the text is the same as the currently shown tooltip, the tip will
not
move. You can force moving by first hiding the tip with an empty text, and then showing the new tip at the new position.
PySide2.QtWidgets.QToolTip.
showText
(
pos
,
text
,
w
,
rect
,
msecShowTime
)
¶
pos
–
QPoint
text – unicode
w
–
QWidget
rect
–
QRect
msecShowTime
–
int
这是重载函数。
This is similar to
showText
(
pos
,
text
,
w
,
rect
) but with an extra parameter
msecDisplayTime
that specifies how long the tool tip will be displayed, in milliseconds.
PySide2.QtWidgets.QToolTip.
text
(
)
¶
unicode
Returns the tooltip text, if a tooltip is visible, or an empty string if a tooltip is not visible.