Class SBGUIToolTip#
The SBGUIToolTip class provides a custom tooltip widget with rich-text and clickable link support.
#include <SBGUIToolTip.hpp>
Inherits the following classes: QWidget
Public Types#
| Type | Name |
|---|---|
| typedef std::function< void(const QString &href)> | LinkHandler Type for a global link handler (receives the full href, e.g. "action://UUID" or "https://..."). |
| typedef std::function< void(const QString &href)> | LinkHoverHandler |
Public Functions#
| Type | Name |
|---|---|
| SBGUIToolTip (QWidget * parent=nullptr) Constructs a SBGUIToolTip widget with an optional parent. |
|
| QLabel * | getLabel () const Access internal label (useful if you also show manual tooltips). |
| void | setHtml (QString htmlOrPlain) Sets the tooltip text using either HTML or plain text. |
| void | showAt (const QPoint & globalAnchor) Shows the tooltip near a global screen position, adjusting its placement to stay within screen bounds. |
Public Static Functions#
| Type | Name |
|---|---|
| void | installFor (QWidget * target) Installs a tooltip filter on a specific widget, enabling custom tooltip handling for that widget. |
| void | installFor (QApplication * app) Installs a global tooltip filter on the application, enabling custom tooltip handling across the entire application. |
| void | setGlobalLinkHandler (LinkHandler handler) Sets a global link handler used by tooltips installed via installFor(&app). |
| void | setGlobalLinkHoverHandler (LinkHoverHandler handler) Sets a global link hover handler to be called when the mouse hovers over a link in a tooltip. |
Protected Functions#
| Type | Name |
|---|---|
| void | enterEvent (QEnterEvent * e) override Handles the event when the mouse enters the tooltip widget. |
| bool | eventFilter (QObject * obj, QEvent * event) override Filters events for the tooltip widget to manage visibility and cursor handling. |
| void | leaveEvent (QEvent * e) override Handles the event when the mouse leaves the tooltip widget. |
| void | paintEvent (QPaintEvent * e) override Paints the tooltip widget using the style's widget primitive. |
Public Types Documentation#
typedef LinkHandler#
Type for a global link handler (receives the full href, e.g. "action://UUID" or "https://...").
typedef LinkHoverHandler#
Public Functions Documentation#
function SBGUIToolTip#
Constructs a SBGUIToolTip widget with an optional parent.
Parameters:
parentThe parent widget for the tooltip. If nullptr, the tooltip has no parent.
function getLabel#
Access internal label (useful if you also show manual tooltips).
Returns the internal QLabel used to display the tooltip content.
Returns:
Pointer to the QLabel instance.
function setHtml#
Sets the tooltip text using either HTML or plain text.
If plain text is provided, it will be escaped and wrapped in a <span> element.
Parameters:
htmlOrPlainThe HTML or plain text to display in the tooltip.
function showAt#
Shows the tooltip near a global screen position, adjusting its placement to stay within screen bounds.
Parameters:
globalAnchorThe global screen position used as the anchor point for the tooltip.
Public Static Functions Documentation#
function installFor [1/2]#
Installs a tooltip filter on a specific widget, enabling custom tooltip handling for that widget.
Parameters:
targetThe widget on which to install the tooltip filter.
function installFor [2/2]#
Installs a global tooltip filter on the application, enabling custom tooltip handling across the entire application.
Parameters:
appPointer to the QApplication instance.
function setGlobalLinkHandler#
Sets a global link handler used by tooltips installed via installFor(&app).
Sets a global link handler used for link activation in tooltips installed via installFor(&app).
If set, every link click in any tooltip calls this callback. You can route "action://..." here. If unset, http(s) links will open with QDesktopServices.
Parameters:
handlerThe callback to be invoked with the href of the clicked link.
function setGlobalLinkHoverHandler#
Sets a global link hover handler to be called when the mouse hovers over a link in a tooltip.
Parameters:
hThe callback receiving the href of the hovered link.
Protected Functions Documentation#
function enterEvent#
Handles the event when the mouse enters the tooltip widget.
Stops the inactivity timer to keep the tooltip visible.
Parameters:
eEnter event.
function eventFilter#
Filters events for the tooltip widget to manage visibility and cursor handling.
Handles application/window deactivation and mouse button presses outside the tooltip to hide it.
Parameters:
objThe object that received the event.eventThe event to filter.
Returns:
true if the event is filtered and further processing should stop; otherwise false.
function leaveEvent#
Handles the event when the mouse leaves the tooltip widget.
Restores the cursor and may hide the tooltip after a short delay if the mouse does not re-enter.
Parameters:
eLeave event.
function paintEvent#
Paints the tooltip widget using the style's widget primitive.
Parameters:
ePaint event (unused).