summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qcursor.3qt
blob: eb083cc4596a7c503cfd4f8de0a5902ba2803ee5 (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
'\" t
.TH QCursor 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
QCursor \- Mouse cursor with an arbitrary shape
.SH SYNOPSIS
\fC#include <qcursor.h>\fR
.PP
Inherits Qt.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQCursor\fR ()"
.br
.ti -1c
.BI "\fBQCursor\fR ( int shape )"
.br
.ti -1c
.BI "\fBQCursor\fR ( const QBitmap & bitmap, const QBitmap & mask, int hotX = -1, int hotY = -1 )"
.br
.ti -1c
.BI "\fBQCursor\fR ( const QPixmap & pixmap, int hotX = -1, int hotY = -1 )"
.br
.ti -1c
.BI "\fBQCursor\fR ( const QCursor & c )"
.br
.ti -1c
.BI "\fB~QCursor\fR ()"
.br
.ti -1c
.BI "QCursor & \fBoperator=\fR ( const QCursor & c )"
.br
.ti -1c
.BI "int \fBshape\fR () const"
.br
.ti -1c
.BI "void \fBsetShape\fR ( int shape )"
.br
.ti -1c
.BI "const QBitmap * \fBbitmap\fR () const"
.br
.ti -1c
.BI "const QBitmap * \fBmask\fR () const"
.br
.ti -1c
.BI "QPoint \fBhotSpot\fR () const"
.br
.ti -1c
.BI "HCURSOR \fBhandle\fR () const"
.br
.ti -1c
.BI "\fBQCursor\fR ( HCURSOR handle )"
.br
.ti -1c
.BI "HANDLE \fBhandle\fR () const"
.br
.in -1c
.SS "Static Public Members"
.in +1c
.ti -1c
.BI "QPoint \fBpos\fR ()"
.br
.ti -1c
.BI "void \fBsetPos\fR ( int x, int y )"
.br
.ti -1c
.BI "void \fBsetPos\fR ( const QPoint & )"
.br
.ti -1c
.BI "void \fBinitialize\fR ()"
.br
.ti -1c
.BI "void \fBcleanup\fR ()"
.br
.in -1c
.SH RELATED FUNCTION DOCUMENTATION
.in +1c
.ti -1c
.BI "QDataStream & \fBoperator<<\fR ( QDataStream & s, const QCursor & c )"
.br
.ti -1c
.BI "QDataStream & \fBoperator>>\fR ( QDataStream & s, QCursor & c )"
.br
.in -1c
.SH DESCRIPTION
The QCursor class provides a mouse cursor with an arbitrary shape.
.PP
This class is mainly used to create mouse cursors that are associated with particular widgets and to get and set the position of the mouse cursor.
.PP
Qt has a number of standard cursor shapes, but you can also make custom cursor shapes based on a QBitmap, a mask and a hotspot.
.PP
To associate a cursor with a widget, use QWidget::setCursor(). To associate a cursor with all widgets (normally for a short period of time), use QApplication::setOverrideCursor().
.PP
To set a cursor shape use QCursor::setShape() or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the CursorShape enum.
.PP
If you want to create a cursor with your own bitmap, either use the QCursor constructor which takes a bitmap and a mask or the constructor which takes a pixmap as arguments.
.PP
To set or get the position of the mouse cursor use the static methods QCursor::pos() and QCursor::setPos().
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
See also QWidget, GUI Design Handbook: Cursors, Widget Appearance and Style, and Implicitly and Explicitly Shared Classes.
.PP
On X11, Qt supports the Xcursor library, which allows for full color icon themes. The table below shows the cursor name used for each Qt::CursorShape value. If a cursor cannot be found using the name shown below, a standard X11 cursor will be used instead. Note: X11 does not provide appropriate cursors for all possible Qt::CursorShape values. It is possible that some cursors will be taken from the Xcursor theme, while others will use an internal bitmap cursor.
.PP
<center>.nf
.TS
l - l. Qt::CursorShape Values Cursor Names Qt::ArrowCursor left_ptr Qt::UpArrowCursor up_arrow Qt::CrossCursor cross Qt::WaitCursor wait Qt::BusyCursor left_ptr_watch Qt::IbeamCursor ibeam Qt::SizeVerCursor size_ver Qt::SizeHorCursor size_hor Qt::SizeBDiagCursor size_bdiag Qt::SizeFDiagCursor size_fdiag Qt::SizeAllCursor size_all Qt::SplitVCursor split_v Qt::SplitHCursor split_h Qt::PointingHandCursor pointing_hand Qt::ForbiddenCursor forbidden Qt::WhatsThisCursor
.TE
.fi
</center>
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QCursor::QCursor ()"
Constructs a cursor with the default arrow shape.
.SH "QCursor::QCursor ( int shape )"
Constructs a cursor with the specified \fIshape\fR.
.PP
See CursorShape for a list of shapes.
.PP
See also setShape().
.SH "QCursor::QCursor ( const QBitmap & bitmap, const QBitmap & mask, int hotX = -1, int hotY = -1 )"
Constructs a custom bitmap cursor.
.PP
\fIbitmap\fR and \fImask\fR make up the bitmap. \fIhotX\fR and \fIhotY\fR define the cursor's hot spot.
.PP
If \fIhotX\fR is negative, it is set to the \fCbitmap().width()/2\fR. If \fIhotY\fR is negative, it is set to the \fCbitmap().height()/2\fR.
.PP
The cursor \fIbitmap\fR (B) and \fImask\fR (M) bits are combined like this:
.TP
B=1 and M=1 gives black.
.TP
B=0 and M=1 gives white.
.TP
B=0 and M=0 gives transparent.
.TP
B=1 and M=0 gives an undefined result.
.PP
Use the global Qt color \fCcolor0\fR to draw 0-pixels and \fCcolor1\fR to draw 1-pixels in the bitmaps.
.PP
Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32x32 cursors, because this size is supported on all platforms. Some platforms also support 16x16, 48x48 and 64x64 cursors.
.PP
See also QBitmap::QBitmap() and QBitmap::setMask().
.SH "QCursor::QCursor ( const QPixmap & pixmap, int hotX = -1, int hotY = -1 )"
Constructs a custom pixmap cursor.
.PP
\fIpixmap\fR is the image. It is usual to give it a mask (set using QPixmap::setMask()). \fIhotX\fR and \fIhotY\fR define the cursor's hot spot.
.PP
If \fIhotX\fR is negative, it is set to the \fCpixmap().width()/2\fR. If \fIhotY\fR is negative, it is set to the \fCpixmap().height()/2\fR.
.PP
Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32x32 cursors, because this size is supported on all platforms. Some platforms also support 16x16, 48x48 and 64x64 cursors.
.PP
Currently, only black-and-white pixmaps can be used.
.PP
See also QPixmap::QPixmap() and QPixmap::setMask().
.SH "QCursor::QCursor ( const QCursor & c )"
Constructs a copy of the cursor \fIc\fR.
.SH "QCursor::QCursor ( HCURSOR handle )"
Creates a cursor with the specified window system handle \fIhandle\fR.
.PP
\fBWarning:\fR Portable in principle, but if you use it you are probably about to do something non-portable. Be careful.
.SH "QCursor::~QCursor ()"
Destroys the cursor.
.SH "const QBitmap * QCursor::bitmap () const"
Returns the cursor bitmap, or 0 if it is one of the standard cursors.
.SH "void QCursor::cleanup ()\fC [static]\fR"
Internal function that deinitializes the predefined cursors. This function is called from the QApplication destructor.
.PP
See also initialize().
.SH "HANDLE QCursor::handle () const"
Returns the window system cursor handle.
.PP
\fBWarning:\fR Portable in principle, but if you use it you are probably about to do something non-portable. Be careful.
.SH "QPoint QCursor::hotSpot () const"
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
.SH "void QCursor::initialize ()\fC [static]\fR"
Internal function that initializes the predefined cursors. This function is called from the QApplication constructor.
.PP
See also cleanup().
.SH "const QBitmap * QCursor::mask () const"
Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.
.SH "QCursor & QCursor::operator= ( const QCursor & c )"
Assigns \fIc\fR to this cursor and returns a reference to this cursor.
.SH "QPoint QCursor::pos ()\fC [static]\fR"
Returns the position of the cursor (hot spot) in global screen coordinates.
.PP
You can call QWidget::mapFromGlobal() to translate it to widget coordinates.
.PP
See also setPos(), QWidget::mapFromGlobal(), and QWidget::mapToGlobal().
.PP
Examples:
.)l chart/canvasview.cpp, fileiconview/qfileiconview.cpp, and menu/menu.cpp.
.SH "void QCursor::setPos ( int x, int y )\fC [static]\fR"
Moves the cursor (hot spot) to the global screen position (\fIx\fR, \fIy\fR).
.PP
You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.
.PP
See also pos(), QWidget::mapFromGlobal(), and QWidget::mapToGlobal().
.SH "void QCursor::setPos ( const QPoint & )\fC [static]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.SH "void QCursor::setShape ( int shape )"
Sets the cursor to the shape identified by \fIshape\fR.
.PP
See CursorShape for the list of cursor shapes.
.PP
See also shape().
.SH "int QCursor::shape () const"
Returns the cursor shape identifier. The return value is one of the CursorShape enum values (cast to an int).
.PP
See also setShape().
.SH RELATED FUNCTION DOCUMENTATION
.SH "QDataStream & operator<< ( QDataStream & s, const QCursor & c )"
Writes the cursor \fIc\fR to the stream \fIs\fR.
.PP
See also Format of the QDataStream operators.
.SH "QDataStream & operator>> ( QDataStream & s, QCursor & c )"
Reads a cursor from the stream \fIs\fR and sets \fIc\fR to the read data.
.PP
See also Format of the QDataStream operators.

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qcursor.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 [email protected] .
Please include the name of the manual page (qcursor.3qt) and the Qt
version (3.3.8).