summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qtooltip.3qt
blob: 2511f9ed49a0d01527ffa188941d3930a055c447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
'\" t
.TH QToolTip 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QToolTip \- Tool tips (balloon help) for any widget or rectangular part of a widget
.SH SYNOPSIS
\fC#include <qtooltip.h>\fR
.PP
Inherits Qt.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQToolTip\fR ( QWidget * widget, QToolTipGroup * group = 0 )"
.br
.ti -1c
.BI "QWidget * \fBparentWidget\fR () const"
.br
.ti -1c
.BI "QToolTipGroup * \fBgroup\fR () const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "void \fBadd\fR ( QWidget * widget, const QString & text )"
.br
.ti -1c
.BI "void \fBadd\fR ( QWidget * widget, const QString & text, QToolTipGroup * group, const QString & longText )"
.br
.ti -1c
.BI "void \fBremove\fR ( QWidget * widget )"
.br
.ti -1c
.BI "void \fBadd\fR ( QWidget * widget, const QRect & rect, const QString & text )"
.br
.ti -1c
.BI "void \fBadd\fR ( QWidget * widget, const QRect & rect, const QString & text, QToolTipGroup * group, const QString & groupText )"
.br
.ti -1c
.BI "void \fBremove\fR ( QWidget * widget, const QRect & rect )"
.br
.ti -1c
.BI "QString \fBtextFor\fR ( QWidget * widget, const QPoint & pos = QPoint ( ) )"
.br
.ti -1c
.BI "void \fBhide\fR ()"
.br
.ti -1c
.BI "QFont \fBfont\fR ()"
.br
.ti -1c
.BI "void \fBsetFont\fR ( const QFont & font )"
.br
.ti -1c
.BI "QPalette \fBpalette\fR ()"
.br
.ti -1c
.BI "void \fBsetPalette\fR ( const QPalette & palette )"
.br
.ti -1c
.BI "void setEnabled ( bool enable )  \fI(obsolete)\fR"
.br
.ti -1c
.BI "bool enabled ()  \fI(obsolete)\fR"
.br
.ti -1c
.BI "void \fBsetGloballyEnabled\fR ( bool enable )"
.br
.ti -1c
.BI "bool \fBisGloballyEnabled\fR ()"
.br
.ti -1c
.BI "void \fBsetWakeUpDelay\fR ( int i )"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBmaybeTip\fR ( const QPoint & p ) = 0"
.br
.ti -1c
.BI "void \fBtip\fR ( const QRect & rect, const QString & text )"
.br
.ti -1c
.BI "void \fBtip\fR ( const QRect & rect, const QString & text, const QString & groupText )"
.br
.ti -1c
.BI "void \fBtip\fR ( const QRect & rect, const QString & text, const QRect & geometry )"
.br
.ti -1c
.BI "void \fBtip\fR ( const QRect & rect, const QString & text, const QString & groupText, const QRect & geometry )"
.br
.ti -1c
.BI "void \fBclear\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QToolTip class provides tool tips (balloon help) for any widget or rectangular part of a widget.
.PP
The tip is a short, single line of text reminding the user of the widget's or rectangle's function. It is drawn immediately below the region in a distinctive black-on-yellow combination.
.PP
The tip can be any Rich-Text formatted string.
.PP
QToolTipGroup provides a way for tool tips to display another text elsewhere (most often in a status bar).
.PP
At any point in time, QToolTip is either dormant or active. In dormant mode the tips are not shown and in active mode they are. The mode is global, not particular to any one widget.
.PP
QToolTip switches from dormant to active mode when the user hovers the mouse on a tip-etquipped region for a second or so and remains active until the user either clicks a mouse button, presses a key, lets the mouse hover for five seconds or moves the mouse outside \fIall\fR tip-etquipped regions for at least a second.
.PP
The QToolTip class can be used in three different ways: <ol type=1>
.IP 1
Adding a tip to an entire widget.
.IP 2
Adding a tip to a fixed rectangle within a widget.
.IP 3
Adding a tip to a dynamic rectangle within a widget.
.PP
To add a tip to a widget, call the \fIstatic\fR function QToolTip::add() with the widget and tip as arguments:
.PP
.nf
.br
        QToolTip::add( tquitButton, "Leave the application" );
.br
.fi
.PP
This is the simplest and most common use of QToolTip. The tip will be deleted automatically when \fItquitButton\fR is deleted, but you can remove it yourself, too:
.PP
.nf
.br
        QToolTip::remove( tquitButton );
.br
.fi
.PP
You can also display another text (typically in a status bar), courtesy of QToolTipGroup. This example assumes that \fIgrp\fR is a \fCQToolTipGroup *\fR and is already connected to the appropriate status bar:
.PP
.nf
.br
        QToolTip::add( tquitButton, "Leave the application", grp,
.br
                       "Leave the application, prompting to save if necessary" );
.br
        QToolTip::add( closeButton, "Close this window", grp,
.br
                       "Close this window, prompting to save if necessary" );
.br
.fi
.PP
To add a tip to a fixed rectangle within a widget, call the static function QToolTip::add() with the widget, rectangle and tip as arguments. (See the tooltip/tooltip.cpp example.) Again, you can supply a \fCQToolTipGroup *\fR and another text if you want.
.PP
Both of these are one-liners and cover the majority of cases. The third and most general way to use QToolTip retquires you to reimplement a pure virtual function to decide whether to pop up a tool tip. The tooltip/tooltip.cpp example demonstrates this too. This mode can be used to implement tips for text that can move as the user scrolls, for example.
.PP
To use QToolTip like this, you must subclass QToolTip and reimplement maybeTip(). QToolTip calls maybeTip() when a tip should pop up, and maybeTip() decides whether to show a tip.
.PP
Tool tips can be globally disabled using QToolTip::setGloballyEnabled() or disabled in groups with QToolTipGroup::setEnabled().
.PP
You can retrieve the text of a tooltip for a given position within a widget using textFor().
.PP
The global tooltip font and palette can be set with the static setFont() and setPalette() functions respectively.
.PP
See also QStatusBar, QWhatsThis, QToolTipGroup, GUI Design Handbook: Tool Tip, and Help System.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QToolTip::QToolTip ( QWidget * widget, QToolTipGroup * group = 0 )"
Constructs a tool tip object. This is only necessary if you need tool tips on regions that can move within the widget (most often because the widget's contents can scroll).
.PP
\fIwidget\fR is the widget you want to add dynamic tool tips to and \fIgroup\fR (optional) is the tool tip group they should belong to.
.PP
\fBWarning:\fR QToolTip is not a subclass of QObject, so the instance of QToolTip is not deleted when \fIwidget\fR is deleted.
.PP
\fBWarning:\fR If you delete the tool tip before you have deleted \fIwidget\fR then you need to make sure you call remove() yourself from \fIwidget\fR in your reimplemented QToolTip destructor.
.PP
.nf
.br
        MyToolTip::~MyToolTip()
.br
        {
.br
            remove( widget );
.br
        }
.br
.fi
.PP
See also maybeTip().
.SH "void QToolTip::add ( QWidget * widget, const QString & text )\fC [static]\fR"
Adds a tool tip to \fIwidget\fR. \fItext\fR is the text to be shown in the tool tip.
.PP
This is the most common entry point to the QToolTip class; it is suitable for adding tool tips to buttons, checkboxes, comboboxes and so on.
.PP
Examples:
.)l helpsystem/mainwindow.cpp, qdir/qdir.cpp, scribble/scribble.cpp, and tooltip/tooltip.cpp.
.SH "void QToolTip::add ( QWidget * widget, const QString & text, QToolTipGroup * group, const QString & longText )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Adds a tool tip to \fIwidget\fR and to tool tip group \fIgroup\fR.
.PP
\fItext\fR is the text shown in the tool tip and \fIlongText\fR is the text emitted from \fIgroup\fR.
.PP
Normally, \fIlongText\fR is shown in a status bar or similar.
.SH "void QToolTip::add ( QWidget * widget, const QRect & rect, const QString & text )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Adds a tool tip to a fixed rectangle, \fIrect\fR, within \fIwidget\fR. \fItext\fR is the text shown in the tool tip.
.SH "void QToolTip::add ( QWidget * widget, const QRect & rect, const QString & text, QToolTipGroup * group, const QString & groupText )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Adds a tool tip to an entire \fIwidget\fR and to tool tip group \fIgroup\fR. The tooltip will disappear when the mouse leaves the \fIrect\fR.
.PP
\fItext\fR is the text shown in the tool tip and \fIgroupText\fR is the text emitted from \fIgroup\fR.
.PP
Normally, \fIgroupText\fR is shown in a status bar or similar.
.SH "void QToolTip::clear ()\fC [protected]\fR"
Immediately removes all tool tips for this tooltip's parent widget.
.SH "bool QToolTip::enabled ()\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.SH "QFont QToolTip::font ()\fC [static]\fR"
Returns the font common to all tool tips.
.PP
See also setFont().
.SH "QToolTipGroup * QToolTip::group () const"
Returns the tool tip group this QToolTip is a member of or 0 if it isn't a member of any group.
.PP
The tool tip group is the object responsible for maintaining contact between tool tips and a status bar or something else which can show the longer help text.
.PP
See also parentWidget() and QToolTipGroup.
.SH "void QToolTip::hide ()\fC [static]\fR"
Hides any tip that is currently being shown.
.PP
Normally, there is no need to call this function; QToolTip takes care of showing and hiding the tips as the user moves the mouse.
.SH "bool QToolTip::isGloballyEnabled ()\fC [static]\fR"
Returns whether tool tips are enabled globally.
.PP
See also setGloballyEnabled().
.SH "void QToolTip::maybeTip ( const QPoint & p )\fC [pure virtual protected]\fR"
This pure virtual function is half of the most versatile interface QToolTip offers.
.PP
It is called when there is a possibility that a tool tip should be shown and must decide whether there is a tool tip for the point \fIp\fR in the widget that this QToolTip object relates to. If so, maybeTip() must call tip() with the rectangle the tip applies to, the tip's text and optionally the QToolTipGroup details and the geometry in screen coordinates.
.PP
\fIp\fR is given in that widget's local coordinates. Most maybeTip() implementations will be of the form:
.PP
.nf
.br
        if ( <something> ) {
.br
            tip( <something>, <something> );
.br
        }
.br
.fi
.PP
The first argument to tip() (a rectangle) must encompass \fIp\fR, i.e. the tip must apply to the current mouse position; otherwise QToolTip's operation is undefined.
.PP
Note that the tip will disappear once the mouse moves outside the rectangle you give to tip(), and will not reappear if the mouse moves back in: maybeTip() is called again instead.
.PP
See also tip().
.PP
Examples:
.)l helpsystem/tooltip.cpp and tooltip/tooltip.cpp.
.SH "QPalette QToolTip::palette ()\fC [static]\fR"
Returns the palette common to all tool tips.
.PP
See also setPalette().
.SH "QWidget * QToolTip::parentWidget () const"
Returns the widget this QToolTip applies to.
.PP
The tool tip is destroyed automatically when the parent widget is destroyed.
.PP
See also group().
.SH "void QToolTip::remove ( QWidget * widget )\fC [static]\fR"
Removes the tool tip from \fIwidget\fR.
.PP
If there is more than one tool tip on \fIwidget\fR, only the one covering the entire widget is removed.
.SH "void QToolTip::remove ( QWidget * widget, const QRect & rect )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Removes any tool tip for \fIrect\fR from \fIwidget\fR.
.PP
If there is more than one tool tip on \fIwidget\fR, only the one covering rectangle \fIrect\fR is removed.
.SH "void QToolTip::setEnabled ( bool enable )\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.SH "void QToolTip::setFont ( const QFont & font )\fC [static]\fR"
Sets the font for all tool tips to \fIfont\fR.
.PP
See also font().
.SH "void QToolTip::setGloballyEnabled ( bool enable )\fC [static]\fR"
If \fIenable\fR is TRUE sets all tool tips to be enabled (shown when needed); if \fIenable\fR is FALSE sets all tool tips to be disabled (never shown).
.PP
By default, tool tips are enabled. Note that this function affects all tool tips in the entire application.
.PP
See also QToolTipGroup::enabled.
.SH "void QToolTip::setPalette ( const QPalette & palette )\fC [static]\fR"
Sets the palette for all tool tips to \fIpalette\fR.
.PP
See also palette().
.SH "void QToolTip::setWakeUpDelay ( int i )\fC [static]\fR"
Sets the wakeup delay for all tooltips to \fIi\fR milliseconds.
.SH "QString QToolTip::textFor ( QWidget * widget, const QPoint & pos = QPoint ( ) )\fC [static]\fR"
Returns the tool tip text for \fIwidget\fR at position \fIpos\fR, or QString::null if there is no tool tip for the given widget and position.
.SH "void QToolTip::tip ( const QRect & rect, const QString & text )\fC [protected]\fR"
Immediately pops up a tip saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR (which is given in the coordinate system of the widget this QToolTip relates to).
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.SH "void QToolTip::tip ( const QRect & rect, const QString & text, const QString & groupText )\fC [protected]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip saying \fItext\fR and removes that tip once the cursor moves out of rectangle \fIrect\fR (which is given in the coordinate system of the widget this QToolTip relates to). \fIgroupText\fR is the text emitted from the group.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.SH "void QToolTip::tip ( const QRect & rect, const QString & text, const QRect & geometry )\fC [protected]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip within the rectangle \fIgeometry\fR, saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.PP
If the tip does not fit inside \fIgeometry\fR, the tip expands.
.SH "void QToolTip::tip ( const QRect & rect, const QString & text, const QString & groupText, const QRect & geometry )\fC [protected]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip within the rectangle \fIgeometry\fR, saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR. \fIgroupText\fR is the text emitted from the group. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.PP
If the tip does not fit inside \fIgeometry\fR, the tip expands.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qtooltip.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qtooltip.3qt) and the Qt
version (3.3.8).