NDEVR
API Documentation
QCustomTooltip

Provides tool tips (balloon help) for any widget that usually shows up when a mouse is hovered over a widget for a set amount of time. More...

Public Member Functions

 QCustomTooltip (const StringView &text, const QPointF &pos, QWidget *parent=nullptr)
 Constructs a tooltip with the given text at the specified screen position.
bool eventFilter (QObject *, QEvent *) override
 Filters events to detect mouse movement and other events that should hide or reposition the tooltip.
void hideTip ()
 Hides the tooltip after a short delay.
void hideTipImmediately (int animation_duration=-1)
 Hides the tooltip immediately with an optional fade-out animation.
int margin () const
 Returns the margin around the tooltip text content.
void reuseTip (const StringView &text, const QPointF &pos)
 Reuses the existing tooltip instance with new text and position.
void setTargetOffset (QPoint target_offset)
 Sets an offset from the target position for tooltip placement.
void setTipRect (const QWidget *w, const QRect &r)
 Sets the widget and rectangle region that the tooltip is associated with.
QSize sizeHint () const override
 Returns the recommended size for the tooltip.
bool tipChanged (const QPointF &pos, const QString &text, QObject *o)
 Checks whether the tooltip content or position has changed.
void updateSize (const QPointF &pos)
 Updates the tooltip size and position based on the new screen position.

Static Public Member Functions

static void hide (int animation_duration=-1)
 Hides the currently showing tooltip with an optional fade-out animation.
static bool IsShowing ()
 Checks whether a tooltip is currently being shown.
static QCustomTooltipshow (const StringView &text, const QPointF &pos, const QWidget *w, int animation_duration=-1)
 Shows a tooltip with the given text at the specified position near a widget.

Protected Member Functions

void mouseMoveEvent (QMouseEvent *e) override
 Handles mouse move events to hide the tooltip when the mouse moves away.
void paintEvent (QPaintEvent *e) override
 Paints the tooltip with its custom appearance.
void resizeEvent (QResizeEvent *e) override
 Handles resize events to update the tooltip shape mask.
void timerEvent (QTimerEvent *e) override
 Handles timer events for auto-hiding the tooltip after a delay.

Detailed Description

Provides tool tips (balloon help) for any widget that usually shows up when a mouse is hovered over a widget for a set amount of time.


Definition at line 47 of file QCustomTooltip.h.

Constructor & Destructor Documentation

◆ QCustomTooltip()

QCustomTooltip::QCustomTooltip ( const StringView & text,
const QPointF & pos,
QWidget * parent = nullptr )

Constructs a tooltip with the given text at the specified screen position.

Parameters
[in]textThe tooltip text to display.
[in]posThe screen position where the tooltip should appear.
[in]parentThe parent widget, or nullptr for no parent.

References QCustomTooltip().

Referenced by QCustomTooltip(), and show().

Member Function Documentation

◆ eventFilter()

bool QCustomTooltip::eventFilter ( QObject * ,
QEvent *  )
override

Filters events to detect mouse movement and other events that should hide or reposition the tooltip.

Parameters
[in]objectThe object that generated the event.
[in]eventThe event to filter.
Returns
True if the event was handled, false otherwise.

◆ hide()

void QCustomTooltip::hide ( int animation_duration = -1)
static

Hides the currently showing tooltip with an optional fade-out animation.

Parameters
[in]animation_durationThe fade-out duration in milliseconds, or -1 for default.

◆ hideTipImmediately()

void QCustomTooltip::hideTipImmediately ( int animation_duration = -1)

Hides the tooltip immediately with an optional fade-out animation.

Parameters
[in]animation_durationThe fade-out duration in milliseconds, or -1 for default.

◆ IsShowing()

bool QCustomTooltip::IsShowing ( )
static

Checks whether a tooltip is currently being shown.

Returns
True if a tooltip is visible, false otherwise.

◆ margin()

int QCustomTooltip::margin ( ) const

Returns the margin around the tooltip text content.

Returns
The margin in pixels.

◆ mouseMoveEvent()

void QCustomTooltip::mouseMoveEvent ( QMouseEvent * e)
overrideprotected

Handles mouse move events to hide the tooltip when the mouse moves away.

Parameters
[in]eThe mouse move event.

◆ paintEvent()

void QCustomTooltip::paintEvent ( QPaintEvent * e)
overrideprotected

Paints the tooltip with its custom appearance.

Parameters
[in]eThe paint event.

◆ resizeEvent()

void QCustomTooltip::resizeEvent ( QResizeEvent * e)
overrideprotected

Handles resize events to update the tooltip shape mask.

Parameters
[in]eThe resize event.

◆ reuseTip()

void QCustomTooltip::reuseTip ( const StringView & text,
const QPointF & pos )

Reuses the existing tooltip instance with new text and position.

Parameters
[in]textThe new tooltip text to display.
[in]posThe new screen position for the tooltip.

◆ setTargetOffset()

void QCustomTooltip::setTargetOffset ( QPoint target_offset)

Sets an offset from the target position for tooltip placement.

Parameters
[in]target_offsetThe pixel offset to apply.

◆ setTipRect()

void QCustomTooltip::setTipRect ( const QWidget * w,
const QRect & r )

Sets the widget and rectangle region that the tooltip is associated with.

The tooltip will hide when the mouse leaves this region.

Parameters
[in]wThe widget the tooltip is associated with.
[in]rThe rectangular region within the widget.

◆ show()

QCustomTooltip * QCustomTooltip::show ( const StringView & text,
const QPointF & pos,
const QWidget * w,
int animation_duration = -1 )
static

Shows a tooltip with the given text at the specified position near a widget.

Parameters
[in]textThe tooltip text to display.
[in]posThe screen position where the tooltip should appear.
[in]wThe widget the tooltip is associated with.
[in]animation_durationThe fade-in duration in milliseconds, or -1 for default.
Returns
A pointer to the tooltip instance.

References QCustomTooltip().

◆ sizeHint()

QSize QCustomTooltip::sizeHint ( ) const
override

Returns the recommended size for the tooltip.

Returns
The recommended QSize for layout calculations.

◆ timerEvent()

void QCustomTooltip::timerEvent ( QTimerEvent * e)
overrideprotected

Handles timer events for auto-hiding the tooltip after a delay.

Parameters
[in]eThe timer event.

◆ tipChanged()

bool QCustomTooltip::tipChanged ( const QPointF & pos,
const QString & text,
QObject * o )

Checks whether the tooltip content or position has changed.

Parameters
[in]posThe new position to compare.
[in]textThe new text to compare.
[in]oThe new associated object to compare.
Returns
True if any parameter has changed, false otherwise.

◆ updateSize()

void QCustomTooltip::updateSize ( const QPointF & pos)

Updates the tooltip size and position based on the new screen position.

Parameters
[in]posThe new screen position.

The documentation for this class was generated from the following file: