KToolTipWidget Class
A tooltip that contains a QWidget. More...
Header: | #include <KToolTipWidget> |
CMake: | find_package(KF6 REQUIRED COMPONENTS WidgetsAddons) target_link_libraries(mytarget PRIVATE KF6::WidgetsAddons) |
Since: | 5.30 |
Inherits: | QWidget |
Properties
- hideDelay : int
Public Functions
KToolTipWidget(QWidget *parent = nullptr) | |
int | hideDelay() const |
void | showAt(const QPoint &pos, QWidget *content, QWindow *transientParent) |
void | showBelow(const QRect &rect, QWidget *content, QWindow *transientParent) |
Public Slots
void | hideLater() |
void | setHideDelay(int delay) |
Signals
void | hidden() |
Detailed Description
This widget allows to show a tooltip that contains another widget.
If you only need to show text inside the tooltip, just use QWidget::setToolTip();
To show the tooltip, you need to choose a position on the screen and also pass a transient parent window (recommended on X11 and required on Wayland). Use showAt() if you want to show the tooltip from a specific point. Use showUnder() if you want to show it under a given rectangle.
You can use a single instance of this class to show as many tooltips as you want.
The tooltip does not take ownership of the content widget if the latter already has a parent. While the tooltip is set as parent of the widget (by the layout), the old parent is restored when the widget is replaced by another widget and also when the tooltip is deleted.
Property Documentation
hideDelay : int
Access functions:
int | hideDelay() const |
void | setHideDelay(int delay) |
Member Function Documentation
[explicit]
KToolTipWidget::KToolTipWidget(QWidget *parent = nullptr)
[signal]
void KToolTipWidget::hidden()
The tooltip has been hidden and the tooltip's widget is no longer visible.
This signal can be used to delete the tooltip's widget.
int KToolTipWidget::hideDelay() const
Returns the delay (in ms) after which hideLater() will hide the tooltip.
Default is 500.
Note: Getter function for property hideDelay.
See also hideLater() and setHideDelay().
[slot]
void KToolTipWidget::hideLater()
Hide the tooltip after a delay of hideDelay() ms (to allow interaction with the tooltip's widget).
If hideDelay() is 0, this is equivalent to hide().
See also hideDelay().
[slot]
void KToolTipWidget::setHideDelay(int delay)
Set after how many ms hideLater() will hide the tooltip.
Note: Setter function for property hideDelay.
See also hideLater() and hideDelay().
void KToolTipWidget::showAt(const QPoint &pos, QWidget *content, QWindow *transientParent)
Show a tooltip containing content. The pos() of the tooltip will be pos.
You can call this method multiple times over the same KToolTipWidget instance (previously shown widgets will be removed from the tooltip's layout).
transientParent will be set as the transient parent of the tooltip.
Note: The transient parent is required to show the tooltip on Wayland platforms.
void KToolTipWidget::showBelow(const QRect &rect, QWidget *content, QWindow *transientParent)
Show a tooltip containing content centered below rect. If there is not enough space in the screen below rect, the tooltip will be shown above rect, if possible, or at the bottom of the screen otherwise. You can call this method multiple times over the same KToolTipWidget instance (previously shown widgets will be removed from the tooltip's layout).
Typically rect is the visualRect() of a QAbstractItemView:
TODO qdoc @snippet ktooltipwidget_test.cpp show_tooltip_widget
transientParent will be set as the transient parent of the tooltip.
Note: The transient parent is required to show the tooltip on Wayland platforms.