KDE 4.7 PyKDE API Reference

- KDE's Python API

# ToolTipManager Class Reference

`from PyKDE4.plasma import *`

Inherits: QObject
Namespace: Plasma

## Detailed Description

ToolTipManager plasma/tooltipmanager.h <Plasma/ToolTipManager>

Manages tooltips for QGraphicsWidgets in Plasma

If you want a widget to have a tooltip displayed when the mouse is hovered over it, you should do something like:

     // widget is a QGraphicsWidget*
     Plasma.ToolTipContent data;
     data.mainText = i18n("My Title");
     data.subText = i18n("This is a little tooltip");
     data.image = KIcon("some-icon").pixmap(IconSize(KIconLoader.Desktop));
     Plasma.ToolTipManager.self()->setContent(widget, data);

Note that, since a Plasma.Applet is a QGraphicsWidget, you can use Plasma.ToolTipManager.self()->setContent(this, data); in the applet's init() method to set a tooltip for the whole applet.

The tooltip will be registered automatically by setContent(). It will be automatically unregistered when the associated widget is deleted, freeing the memory used by the tooltip, but you can manually unregister it at any time by calling unregisterWidget().

When a tooltip for a widget is about to be shown, the widget's toolTipAboutToShow() slot will be invoked if it exists. Similarly, when a tooltip is hidden, the widget's toolTipHidden() slot will be invoked if it exists. This allows widgets to provide on-demand tooltip data.

## Enumerations
State | { Activated, Inhibited, Deactivated }
## Signals
| linkActivated (QString anchor, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QPoint screenPos)
| windowPreviewActivated (int window, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, QPoint screenPos)
## Methods
| __init__ (self, QObject parent=0)
| clearContent (self, QGraphicsWidget widget)
| hide (self, QGraphicsWidget widget)
bool | isVisible (self, QGraphicsWidget widget)
| registerWidget (self, QGraphicsWidget widget)
| setContent (self, QGraphicsWidget widget, Plasma.ToolTipContent data)
| setState (self, Plasma.ToolTipManager.State state)
| show (self, QGraphicsWidget widget)
Plasma.ToolTipManager.State | state (self)
| unregisterWidget (self, QGraphicsWidget widget)
## Static Methods
Plasma.ToolTipManager | self ()

## Signal Documentation

linkActivated | ( | QString | anchor,
|  | Qt::MouseButtons | buttons,
|  | Qt::KeyboardModifiers | modifiers,
|  | QPoint | screenPos
| ) |  |  |

This signal is emitted when a link in the tooltip is clicked.

Parameters:

  | anchor | the achor text (e.g. url) that was clicked on
  | buttons | the mouse buttons involved in the activation
  | modifiers | the keyboard modifiers involved in the activation, if any

Since:
  4.4

Signal syntax:
  `QObject.connect(source, SIGNAL("linkActivated(const QString&, Qt::MouseButtons, Qt::KeyboardModifiers, const QPoint&)"), target_slot)`

windowPreviewActivated | ( | int | window,
|  | Qt::MouseButtons | buttons,
|  | Qt::KeyboardModifiers | modifiers,
|  | QPoint | screenPos
| ) |  |  |

This signal is emitted when a window preview in the tooltip is clicked.

Parameters:

  | window | the id of the window that was clicked
  | buttons | the mouse buttons involved in the activation
  | modifiers | the keyboard modifiers involved in the activation, if any

Since:
  4.4

Signal syntax:
  `QObject.connect(source, SIGNAL("windowPreviewActivated(WId, Qt::MouseButtons, Qt::KeyboardModifiers, const QPoint&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Default constructor.

You should normall use self() instead.

clearContent | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Clears the tooltip data associated with this widget, but keeps the widget registered.

hide | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Hides the tooltip for a widget immediately.

Parameters:

  | widget | the widget to hide the tooltip for

bool isVisible | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Find out whether the tooltip for a given widget is currently being displayed.

Parameters:

  | widget | the widget to check the tooltip for

Returns:
  true if the tooltip of the widget is currently displayed, false if not

registerWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Registers a widget with the tooltip manager.

Note that setContent() will register the widget if it has not already been registered, and so you do not normally need to use the method.

This is useful for creating tooltip content on demand. You can register your widget with registerWidget(), then implement a slot named toolTipAboutToShow for the widget. This will be called before the tooltip is shown, allowing you to set the data with setContent().

If the widget also has a toolTipHidden slot, this will be called after the tooltip is hidden.

Parameters:

  | widget | the desired widget

setContent | ( | self, |
|  | QGraphicsWidget | widget,
|  | Plasma.ToolTipContent | data
| ) |  |  |

Sets the content for the tooltip associated with a widget.

Note that this will register the widget with the ToolTipManager if necessary, so there is usually no need to call registerWidget().

Parameters:

  | widget | the widget the tooltip should be associated with
  | data | the content of the tooltip. If an empty Content is passed in, the tooltip content will be reset.

setState | ( | self, |
|  | Plasma.ToolTipManager.State | state
| ) |  |  |

Sets the current state of the manager.

See also:
  State

Parameters:

  | state | the state to put the manager in

show | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Show the tooltip for a widget registered in the tooltip manager

Parameters:

  | widget | the widget for which the tooltip will be displayed

Plasma.ToolTipManager.State state | ( |  | self ) |

Returns:
  the current state of the manager;
  See also:
    State

unregisterWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Unregisters a widget from the tooltip manager.

This will free the memory used by the tooltip associated with the widget.

Parameters:

  | widget | the desired widget to delete

## Static Method Documentation

Plasma.ToolTipManager self | ( |  | ) |

Returns:
  The singleton instance of the manager.

## Enumeration Documentation

State

Enumerator:

  Activated = 0 |
  Inhibited |
  Deactivated |