PySide6.QtWidgets.QToolTip¶
- class QToolTip¶
- The - QToolTipclass provides tool tips (balloon help) for any widget. More…- Synopsis¶- Static functions¶- def - font()
- def - hideText()
- def - isVisible()
- def - palette()
- def - setFont()
- def - setPalette()
- def - showText()
- def - text()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - 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'>.- UI elements that are created via QAction use the tooltip property of the QAction, so for most interactive UI elements, setting that property is the easiest way to provide tool tips. - openAction = QAction(tr("Open...")) openAction.setToolTip(tr("Open an existing file")) fileMenu = menuBar().addMenu(tr("File")) fileToolBar = addToolBar(tr("File")) fileMenu.addAction(openAction) fileToolBar.addAction(openAction) - For any other widgets, the simplest and most common way to set a widget’s tool tip is by calling its - setToolTip()function.- searchBar = SearchBar() searchBar.setToolTip(tr("Search in the current document")) - It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget’s - event()function and call- showText()with the text you want to display.- def event(self, QEvent event): if event.type() == QEvent.ToolTip: helpEvent = QHelpEvent(event) if Element element = elementAt(helpEvent.pos()): QToolTip.showText(helpEvent.globalPos(), element.toolTip()) else: QToolTip.hideText() event.ignore() return True return QWidget.event(event) - If you are calling - hideText(), or- showText()with an empty string, as a result of a ToolTip-event you should also call ignore() 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 the- viewportEvent()function and handle it yourself.- The default tool tip color and font can be customized with - setPalette()and- setFont(). When a tooltip is currently on display,- isVisible()returns- trueand- text()the currently visible text.- Note - Tool tips use the inactive color group of QPalette, because tool tips are not active windows. - See also - toolTip- toolTip- Returns the font used to render tooltips. - See also - static hideText()¶
 - Hides the tool tip. This is the same as calling - showText()with an empty string.- See also - static isVisible()¶
- Return type:
- bool 
 
 - Returns - trueif a tooltip is currently shown.- See also - Returns the palette used to render tooltips. - Note - Tool tips use the inactive color group of QPalette, because tool tips are not active windows. - See also - Sets the - fontused to render tooltips.- See also - Sets the - paletteused to render tooltips.- Note - Tool tips use the inactive color group of QPalette, because tool tips are not active windows. - See also - static showText(pos, text[, w=None[, rect={}[, msecShowTime=-1]]])¶
 - Shows - textas a tool tip, with the global position- posas 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. - The - rectis in the coordinates of the widget you specify with- w. If the- rectis not empty you must specify a widget. Otherwise this argument can be- Nonebut it is used to determine the appropriate screen on multi-head systems.- The - msecDisplayTimeparameter specifies for how long the tool tip will be displayed, in milliseconds. With the default value of -1, the time is based on the length of the text.- If - textis 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.- static text()¶
- Return type:
- str 
 
 - Returns the tooltip text, if a tooltip is visible, or an empty string if a tooltip is not visible.