Qt Reference Documentation

QML ToolTip Element

Provides a tooltip that shows a hint or contextual feedback. More...

This element was introduced in Qt Quick Components 1.0.

Properties

Detailed Description

The contextual feedback can be the value of a determinate progress bar, for example. To display a tooltip, you need to set the text to to be displayed and a component that the tooltip is connected to. The tooltip can be set to visible true or false.

By default, the tooltip is positioned above the object bound to its target. The tooltip will relocate itself automatically if it would be displayed out of the screen's visible area. The display position is determined in the following order: top, right, left, and bottom.

Displaying a ToolTip

The code snippet below illustrates how to show a tooltip when the user presses the rectangle, and hide it when the user releases the rectangle.

     Rectangle {
         id: rectangle
         anchors.centerIn: parent
         width: 50
         height: 50
         color: "white"

         ToolTip {
             id: toolTip
             text: "ToolTip"
             target: rectangle
             visible: mouseArea.pressed
         }

         MouseArea {
             id: mouseArea
             anchors.fill: parent
         }
     }

The screenshot below illustrates the case where the user is pressing the rectangle.

Property Documentation

font : font

The font of the tooltip's label.


platformInverted : bool

Symbian:

If platformInverted is true, the component is visualized with the inverted style. For more information, see Using Inverted Style with Symbian Components. By default platformInverted is false.

This property group was introduced in Qt Quick Components 1.1.


target : variant

The object that the tooltip is connected to. The position of the tooltip is calculated in relation to the element given as the target.


text : string

The text that is displayed as the tooltip's label. The default text is an empty string. The property also accepts rich text.