1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qcursor.cpp:47 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QCursor Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCursor Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QCursor class provides a mouse cursor with an arbitrary
|
---|
35 | shape.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qcursor-h.html">qcursor.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qt.html">Qt</a>.
|
---|
39 | <p><a href="qcursor-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QCursor"><b>QCursor</b></a> ()</li>
|
---|
43 | <li class=fn><a href="#QCursor-2"><b>QCursor</b></a> ( int shape )</li>
|
---|
44 | <li class=fn><a href="#QCursor-3"><b>QCursor</b></a> ( const QBitmap & bitmap, const QBitmap & mask, int hotX = -1, int hotY = -1 )</li>
|
---|
45 | <li class=fn><a href="#QCursor-4"><b>QCursor</b></a> ( const QPixmap & pixmap, int hotX = -1, int hotY = -1 )</li>
|
---|
46 | <li class=fn><a href="#QCursor-5"><b>QCursor</b></a> ( const QCursor & c )</li>
|
---|
47 | <li class=fn><a href="#~QCursor"><b>~QCursor</b></a> ()</li>
|
---|
48 | <li class=fn>QCursor & <a href="#operator-eq"><b>operator=</b></a> ( const QCursor & c )</li>
|
---|
49 | <li class=fn>int <a href="#shape"><b>shape</b></a> () const</li>
|
---|
50 | <li class=fn>void <a href="#setShape"><b>setShape</b></a> ( int shape )</li>
|
---|
51 | <li class=fn>const QBitmap * <a href="#bitmap"><b>bitmap</b></a> () const</li>
|
---|
52 | <li class=fn>const QBitmap * <a href="#mask"><b>mask</b></a> () const</li>
|
---|
53 | <li class=fn>QPoint <a href="#hotSpot"><b>hotSpot</b></a> () const</li>
|
---|
54 | <li class=fn>HCURSOR <b>handle</b> () const</li>
|
---|
55 | <li class=fn><a href="#QCursor-6"><b>QCursor</b></a> ( HCURSOR handle )</li>
|
---|
56 | <li class=fn>HANDLE <a href="#handle"><b>handle</b></a> () const</li>
|
---|
57 | </ul>
|
---|
58 | <h2>Static Public Members</h2>
|
---|
59 | <ul>
|
---|
60 | <li class=fn>QPoint <a href="#pos"><b>pos</b></a> ()</li>
|
---|
61 | <li class=fn>void <a href="#setPos"><b>setPos</b></a> ( int x, int y )</li>
|
---|
62 | <li class=fn>void <a href="#setPos-2"><b>setPos</b></a> ( const QPoint & )</li>
|
---|
63 | <li class=fn>void <a href="#initialize"><b>initialize</b></a> ()</li>
|
---|
64 | <li class=fn>void <a href="#cleanup"><b>cleanup</b></a> ()</li>
|
---|
65 | </ul>
|
---|
66 | <h2>Related Functions</h2>
|
---|
67 | <ul>
|
---|
68 | <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QCursor & c )</li>
|
---|
69 | <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QCursor & c )</li>
|
---|
70 | </ul>
|
---|
71 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
72 |
|
---|
73 |
|
---|
74 | <p> The QCursor class provides a mouse cursor with an arbitrary
|
---|
75 | shape.
|
---|
76 | <p>
|
---|
77 |
|
---|
78 | <p> This class is mainly used to create mouse cursors that are
|
---|
79 | associated with particular widgets and to get and set the position
|
---|
80 | of the mouse cursor.
|
---|
81 | <p> Qt has a number of standard cursor shapes, but you can also make
|
---|
82 | custom cursor shapes based on a <a href="qbitmap.html">QBitmap</a>, a mask and a hotspot.
|
---|
83 | <p> To associate a cursor with a widget, use <a href="qwidget.html#setCursor">QWidget::setCursor</a>(). To
|
---|
84 | associate a cursor with all widgets (normally for a short period
|
---|
85 | of time), use <a href="qapplication.html#setOverrideCursor">QApplication::setOverrideCursor</a>().
|
---|
86 | <p> To set a cursor shape use <a href="#setShape">QCursor::setShape</a>() or use the QCursor
|
---|
87 | constructor which takes the shape as argument, or you can use one
|
---|
88 | of the predefined cursors defined in the <a href="qt.html#CursorShape-enum">CursorShape</a> enum.
|
---|
89 | <p> If you want to create a cursor with your own bitmap, either use
|
---|
90 | the QCursor constructor which takes a bitmap and a mask or the
|
---|
91 | constructor which takes a pixmap as arguments.
|
---|
92 | <p> To set or get the position of the mouse cursor use the static
|
---|
93 | methods <a href="#pos">QCursor::pos</a>() and <a href="#setPos">QCursor::setPos</a>().
|
---|
94 | <p> <center><img src="cursors.png" alt="Cursor Shapes"></center>
|
---|
95 | <p> <p>See also <a href="qwidget.html">QWidget</a>, <a href="guibooks.html#fowler">GUI Design Handbook:
|
---|
96 | Cursors</a>, <a href="appearance.html">Widget Appearance and Style</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
|
---|
97 |
|
---|
98 | <p> On X11, Qt supports the <a href="http://www.xfree86.org/4.3.0/Xcursor.3.html">Xcursor</a>
|
---|
99 | library, which allows for full color icon themes. The table below
|
---|
100 | shows the cursor name used for each Qt::CursorShape value. If a
|
---|
101 | cursor cannot be found using the name shown below, a standard X11
|
---|
102 | cursor will be used instead. Note: X11 does not provide
|
---|
103 | appropriate cursors for all possible Qt::CursorShape values. It
|
---|
104 | is possible that some cursors will be taken from the Xcursor
|
---|
105 | theme, while others will use an internal bitmap cursor.
|
---|
106 | <p> <center><table cellpadding="4" cellspacing="2" border="0">
|
---|
107 | <tr bgcolor="#a2c511"> <th valign="top">Qt::CursorShape Values <th valign="top">Cursor Names
|
---|
108 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::ArrowCursor <td valign="top">left_ptr
|
---|
109 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::UpArrowCursor <td valign="top">up_arrow
|
---|
110 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::CrossCursor <td valign="top">cross
|
---|
111 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::WaitCursor <td valign="top">wait
|
---|
112 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::BusyCursor <td valign="top">left_ptr_watch
|
---|
113 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::IbeamCursor <td valign="top">ibeam
|
---|
114 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeVerCursor <td valign="top">size_ver
|
---|
115 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::SizeHorCursor <td valign="top">size_hor
|
---|
116 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeBDiagCursor <td valign="top">size_bdiag
|
---|
117 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::SizeFDiagCursor <td valign="top">size_fdiag
|
---|
118 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeAllCursor <td valign="top">size_all
|
---|
119 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::SplitVCursor <td valign="top">split_v
|
---|
120 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::SplitHCursor <td valign="top">split_h
|
---|
121 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::PointingHandCursor <td valign="top">pointing_hand
|
---|
122 | <tr bgcolor="#f0f0f0"> <td valign="top">Qt::ForbiddenCursor <td valign="top">forbidden
|
---|
123 | <tr bgcolor="#d0d0d0"> <td valign="top">Qt::WhatsThisCursor <td valign="top">whats_this
|
---|
124 | </table></center>
|
---|
125 |
|
---|
126 | <hr><h2>Member Function Documentation</h2>
|
---|
127 | <h3 class=fn><a name="QCursor"></a>QCursor::QCursor ()
|
---|
128 | </h3>
|
---|
129 | Constructs a cursor with the default arrow shape.
|
---|
130 |
|
---|
131 | <h3 class=fn><a name="QCursor-2"></a>QCursor::QCursor ( int shape )
|
---|
132 | </h3>
|
---|
133 | Constructs a cursor with the specified <em>shape</em>.
|
---|
134 | <p> See <a href="qt.html#CursorShape-enum">CursorShape</a> for a list of shapes.
|
---|
135 | <p> <p>See also <a href="#setShape">setShape</a>().
|
---|
136 |
|
---|
137 | <h3 class=fn><a name="QCursor-3"></a>QCursor::QCursor ( const <a href="qbitmap.html">QBitmap</a> & bitmap, const <a href="qbitmap.html">QBitmap</a> & mask, int hotX = -1, int hotY = -1 )
|
---|
138 | </h3>
|
---|
139 | Constructs a custom bitmap cursor.
|
---|
140 | <p> <em>bitmap</em> and
|
---|
141 | <em>mask</em> make up the bitmap.
|
---|
142 | <em>hotX</em> and
|
---|
143 | <em>hotY</em> define the cursor's hot spot.
|
---|
144 | <p> If <em>hotX</em> is negative, it is set to the <tt>bitmap().width()/2</tt>.
|
---|
145 | If <em>hotY</em> is negative, it is set to the <tt>bitmap().height()/2</tt>.
|
---|
146 | <p> The cursor <em>bitmap</em> (B) and <em>mask</em> (M) bits are combined like this:
|
---|
147 | <ul>
|
---|
148 | <li> B=1 and M=1 gives black.
|
---|
149 | <li> B=0 and M=1 gives white.
|
---|
150 | <li> B=0 and M=0 gives transparent.
|
---|
151 | <li> B=1 and M=0 gives an undefined result.
|
---|
152 | </ul>
|
---|
153 | <p> Use the global Qt color <tt>color0</tt> to draw 0-pixels and <tt>color1</tt> to
|
---|
154 | draw 1-pixels in the bitmaps.
|
---|
155 | <p> Valid cursor sizes depend on the display hardware (or the
|
---|
156 | underlying window system). We recommend using 32x32 cursors,
|
---|
157 | because this size is supported on all platforms. Some platforms
|
---|
158 | also support 16x16, 48x48 and 64x64 cursors.
|
---|
159 | <p> <p>See also <a href="qbitmap.html#QBitmap">QBitmap::QBitmap</a>() and <a href="qpixmap.html#setMask">QBitmap::setMask</a>().
|
---|
160 |
|
---|
161 | <h3 class=fn><a name="QCursor-4"></a>QCursor::QCursor ( const <a href="qpixmap.html">QPixmap</a> & pixmap, int hotX = -1, int hotY = -1 )
|
---|
162 | </h3>
|
---|
163 | Constructs a custom pixmap cursor.
|
---|
164 | <p> <em>pixmap</em> is the image. It is usual to give it a mask (set using
|
---|
165 | <a href="qpixmap.html#setMask">QPixmap::setMask</a>()). <em>hotX</em> and <em>hotY</em> define the cursor's hot
|
---|
166 | spot.
|
---|
167 | <p> If <em>hotX</em> is negative, it is set to the <tt>pixmap().width()/2</tt>.
|
---|
168 | If <em>hotY</em> is negative, it is set to the <tt>pixmap().height()/2</tt>.
|
---|
169 | <p> Valid cursor sizes depend on the display hardware (or the
|
---|
170 | underlying window system). We recommend using 32x32 cursors,
|
---|
171 | because this size is supported on all platforms. Some platforms
|
---|
172 | also support 16x16, 48x48 and 64x64 cursors.
|
---|
173 | <p> Currently, only black-and-white pixmaps can be used.
|
---|
174 | <p> <p>See also <a href="qpixmap.html#QPixmap">QPixmap::QPixmap</a>() and <a href="qpixmap.html#setMask">QPixmap::setMask</a>().
|
---|
175 |
|
---|
176 | <h3 class=fn><a name="QCursor-5"></a>QCursor::QCursor ( const <a href="qcursor.html">QCursor</a> & c )
|
---|
177 | </h3>
|
---|
178 | Constructs a copy of the cursor <em>c</em>.
|
---|
179 |
|
---|
180 | <h3 class=fn><a name="QCursor-6"></a>QCursor::QCursor ( HCURSOR handle )
|
---|
181 | </h3>
|
---|
182 |
|
---|
183 | <p> Creates a cursor with the specified window system handle <em>handle</em>.
|
---|
184 | <p> <b>Warning:</b>
|
---|
185 | Portable in principle, but if you use it you are probably about to
|
---|
186 | do something non-portable. Be careful.
|
---|
187 |
|
---|
188 | <h3 class=fn><a name="~QCursor"></a>QCursor::~QCursor ()
|
---|
189 | </h3>
|
---|
190 | Destroys the cursor.
|
---|
191 |
|
---|
192 | <h3 class=fn>const <a href="qbitmap.html">QBitmap</a> * <a name="bitmap"></a>QCursor::bitmap () const
|
---|
193 | </h3>
|
---|
194 | Returns the cursor bitmap, or 0 if it is one of the standard
|
---|
195 | cursors.
|
---|
196 |
|
---|
197 | <h3 class=fn>void <a name="cleanup"></a>QCursor::cleanup ()<tt> [static]</tt>
|
---|
198 | </h3>
|
---|
199 | Internal function that deinitializes the predefined cursors.
|
---|
200 | This function is called from the <a href="qapplication.html">QApplication</a> destructor.
|
---|
201 | <p> <p>See also <a href="#initialize">initialize</a>().
|
---|
202 |
|
---|
203 | <h3 class=fn>HANDLE <a name="handle"></a>QCursor::handle () const
|
---|
204 | </h3>
|
---|
205 | Returns the window system cursor handle.
|
---|
206 | <p> <b>Warning:</b>
|
---|
207 | Portable in principle, but if you use it you are probably about to
|
---|
208 | do something non-portable. Be careful.
|
---|
209 |
|
---|
210 | <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="hotSpot"></a>QCursor::hotSpot () const
|
---|
211 | </h3>
|
---|
212 | Returns the cursor hot spot, or (0, 0) if it is one of the
|
---|
213 | standard cursors.
|
---|
214 |
|
---|
215 | <h3 class=fn>void <a name="initialize"></a>QCursor::initialize ()<tt> [static]</tt>
|
---|
216 | </h3>
|
---|
217 | Internal function that initializes the predefined cursors.
|
---|
218 | This function is called from the <a href="qapplication.html">QApplication</a> constructor.
|
---|
219 | <p> <p>See also <a href="#cleanup">cleanup</a>().
|
---|
220 |
|
---|
221 | <h3 class=fn>const <a href="qbitmap.html">QBitmap</a> * <a name="mask"></a>QCursor::mask () const
|
---|
222 | </h3>
|
---|
223 | Returns the cursor bitmap mask, or 0 if it is one of the standard
|
---|
224 | cursors.
|
---|
225 |
|
---|
226 | <h3 class=fn><a href="qcursor.html">QCursor</a> & <a name="operator-eq"></a>QCursor::operator= ( const <a href="qcursor.html">QCursor</a> & c )
|
---|
227 | </h3>
|
---|
228 | Assigns <em>c</em> to this cursor and returns a reference to this
|
---|
229 | cursor.
|
---|
230 |
|
---|
231 | <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="pos"></a>QCursor::pos ()<tt> [static]</tt>
|
---|
232 | </h3>
|
---|
233 | Returns the position of the cursor (hot spot) in global screen
|
---|
234 | coordinates.
|
---|
235 | <p> You can call <a href="qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>() to translate it to widget
|
---|
236 | coordinates.
|
---|
237 | <p> <p>See also <a href="#setPos">setPos</a>(), <a href="qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().
|
---|
238 |
|
---|
239 | <p>Examples: <a href="tutorial2-06.html#x2579">chart/canvasview.cpp</a>, <a href="fileiconview-example.html#x809">fileiconview/qfileiconview.cpp</a>, and <a href="menu-example.html#x1859">menu/menu.cpp</a>.
|
---|
240 | <h3 class=fn>void <a name="setPos"></a>QCursor::setPos ( int x, int y )<tt> [static]</tt>
|
---|
241 | </h3>
|
---|
242 | Moves the cursor (hot spot) to the global screen position (<em>x</em>,
|
---|
243 | <em>y</em>).
|
---|
244 | <p> You can call <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() to translate widget
|
---|
245 | coordinates to global screen coordinates.
|
---|
246 | <p> <p>See also <a href="#pos">pos</a>(), <a href="qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>(), and <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().
|
---|
247 |
|
---|
248 | <h3 class=fn>void <a name="setPos-2"></a>QCursor::setPos ( const <a href="qpoint.html">QPoint</a> & )<tt> [static]</tt>
|
---|
249 | </h3>
|
---|
250 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
251 | <p>
|
---|
252 | <h3 class=fn>void <a name="setShape"></a>QCursor::setShape ( int shape )
|
---|
253 | </h3>
|
---|
254 | Sets the cursor to the shape identified by <em>shape</em>.
|
---|
255 | <p> See <a href="qt.html#CursorShape-enum">CursorShape</a> for the list of cursor shapes.
|
---|
256 | <p> <p>See also <a href="#shape">shape</a>().
|
---|
257 |
|
---|
258 | <h3 class=fn>int <a name="shape"></a>QCursor::shape () const
|
---|
259 | </h3>
|
---|
260 | Returns the cursor shape identifier. The return value is one of
|
---|
261 | the <a href="qt.html#CursorShape-enum">CursorShape</a> enum values (cast to an int).
|
---|
262 | <p> <p>See also <a href="#setShape">setShape</a>().
|
---|
263 |
|
---|
264 | <hr><h2>Related Functions</h2>
|
---|
265 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qcursor.html">QCursor</a> & c )
|
---|
266 | </h3>
|
---|
267 |
|
---|
268 | Writes the cursor <em>c</em> to the stream <em>s</em>.
|
---|
269 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
270 |
|
---|
271 | <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qcursor.html">QCursor</a> & c )
|
---|
272 | </h3>
|
---|
273 |
|
---|
274 | Reads a cursor from the stream <em>s</em> and sets <em>c</em> to the read data.
|
---|
275 | <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
|
---|
276 |
|
---|
277 | <!-- eof -->
|
---|
278 | <hr><p>
|
---|
279 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
280 | Copyright © 1995-2007
|
---|
281 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
282 | <table width=100% cellspacing=0 border=0><tr>
|
---|
283 | <td>Copyright © 2007
|
---|
284 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
285 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
286 | </table></div></address></body>
|
---|
287 | </html>
|
---|