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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/harald/tmp/qt-3.3.7-harald-4508/qt-x11-free-3.3.7/src/kernel/qcursor.cpp:47 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QCursor Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<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>
<p>The QCursor class provides a mouse cursor with an arbitrary
shape.
<a href="#details">More...</a>
<p><tt>#include <<a href="qcursor-h.html">qcursor.h</a>></tt>
<p>Inherits <a href="qt.html">Qt</a>.
<p><a href="qcursor-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QCursor"><b>QCursor</b></a> ()</li>
<li class=fn><a href="#QCursor-2"><b>QCursor</b></a> ( int shape )</li>
<li class=fn><a href="#QCursor-3"><b>QCursor</b></a> ( const QBitmap & bitmap, const QBitmap & mask, int hotX = -1, int hotY = -1 )</li>
<li class=fn><a href="#QCursor-4"><b>QCursor</b></a> ( const QPixmap & pixmap, int hotX = -1, int hotY = -1 )</li>
<li class=fn><a href="#QCursor-5"><b>QCursor</b></a> ( const QCursor & c )</li>
<li class=fn><a href="#~QCursor"><b>~QCursor</b></a> ()</li>
<li class=fn>QCursor & <a href="#operator-eq"><b>operator=</b></a> ( const QCursor & c )</li>
<li class=fn>int <a href="#shape"><b>shape</b></a> () const</li>
<li class=fn>void <a href="#setShape"><b>setShape</b></a> ( int shape )</li>
<li class=fn>const QBitmap * <a href="#bitmap"><b>bitmap</b></a> () const</li>
<li class=fn>const QBitmap * <a href="#mask"><b>mask</b></a> () const</li>
<li class=fn>QPoint <a href="#hotSpot"><b>hotSpot</b></a> () const</li>
<li class=fn>HCURSOR <b>handle</b> () const</li>
<li class=fn><a href="#QCursor-6"><b>QCursor</b></a> ( HCURSOR handle )</li>
<li class=fn>HANDLE <a href="#handle"><b>handle</b></a> () const</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>QPoint <a href="#pos"><b>pos</b></a> ()</li>
<li class=fn>void <a href="#setPos"><b>setPos</b></a> ( int x, int y )</li>
<li class=fn>void <a href="#setPos-2"><b>setPos</b></a> ( const QPoint & )</li>
<li class=fn>void <a href="#initialize"><b>initialize</b></a> ()</li>
<li class=fn>void <a href="#cleanup"><b>cleanup</b></a> ()</li>
</ul>
<h2>Related Functions</h2>
<ul>
<li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QCursor & c )</li>
<li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QCursor & c )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
<p> The QCursor class provides a mouse cursor with an arbitrary
shape.
<p>
<p> 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.
<p> Qt has a number of standard cursor shapes, but you can also make
custom cursor shapes based on a <a href="qbitmap.html">QBitmap</a>, a mask and a hotspot.
<p> To associate a cursor with a widget, use <a href="qwidget.html#setCursor">QWidget::setCursor</a>(). To
associate a cursor with all widgets (normally for a short period
of time), use <a href="qapplication.html#setOverrideCursor">QApplication::setOverrideCursor</a>().
<p> To set a cursor shape use <a href="#setShape">QCursor::setShape</a>() or use the QCursor
constructor which takes the shape as argument, or you can use one
of the predefined cursors defined in the <a href="qt.html#CursorShape-enum">CursorShape</a> enum.
<p> 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.
<p> To set or get the position of the mouse cursor use the static
methods <a href="#pos">QCursor::pos</a>() and <a href="#setPos">QCursor::setPos</a>().
<p> <center><img src="cursors.png" alt="Cursor Shapes"></center>
<p> <p>See also <a href="qwidget.html">QWidget</a>, <a href="guibooks.html#fowler">GUI Design Handbook:
Cursors</a>, <a href="appearance.html">Widget Appearance and Style</a>, and <a href="shared.html">Implicitly and Explicitly Shared Classes</a>.
<p> On X11, Qt supports the <a href="http://www.xfree86.org/4.3.0/Xcursor.3.html">Xcursor</a>
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.
<p> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Qt::CursorShape Values <th valign="top">Cursor Names
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::ArrowCursor <td valign="top">left_ptr
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::UpArrowCursor <td valign="top">up_arrow
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::CrossCursor <td valign="top">cross
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::WaitCursor <td valign="top">wait
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::BusyCursor <td valign="top">left_ptr_watch
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::IbeamCursor <td valign="top">ibeam
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeVerCursor <td valign="top">size_ver
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::SizeHorCursor <td valign="top">size_hor
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeBDiagCursor <td valign="top">size_bdiag
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::SizeFDiagCursor <td valign="top">size_fdiag
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::SizeAllCursor <td valign="top">size_all
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::SplitVCursor <td valign="top">split_v
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::SplitHCursor <td valign="top">split_h
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::PointingHandCursor <td valign="top">pointing_hand
<tr bgcolor="#f0f0f0"> <td valign="top">Qt::ForbiddenCursor <td valign="top">forbidden
<tr bgcolor="#d0d0d0"> <td valign="top">Qt::WhatsThisCursor <td valign="top">whats_this
</table></center>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QCursor"></a>QCursor::QCursor ()
</h3>
Constructs a cursor with the default arrow shape.
<h3 class=fn><a name="QCursor-2"></a>QCursor::QCursor ( int shape )
</h3>
Constructs a cursor with the specified <em>shape</em>.
<p> See <a href="qt.html#CursorShape-enum">CursorShape</a> for a list of shapes.
<p> <p>See also <a href="#setShape">setShape</a>().
<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 )
</h3>
Constructs a custom bitmap cursor.
<p> <em>bitmap</em> and
<em>mask</em> make up the bitmap.
<em>hotX</em> and
<em>hotY</em> define the cursor's hot spot.
<p> If <em>hotX</em> is negative, it is set to the <tt>bitmap().width()/2</tt>.
If <em>hotY</em> is negative, it is set to the <tt>bitmap().height()/2</tt>.
<p> The cursor <em>bitmap</em> (B) and <em>mask</em> (M) bits are combined like this:
<ul>
<li> B=1 and M=1 gives black.
<li> B=0 and M=1 gives white.
<li> B=0 and M=0 gives transparent.
<li> B=1 and M=0 gives an undefined result.
</ul>
<p> Use the global Qt color <tt>color0</tt> to draw 0-pixels and <tt>color1</tt> to
draw 1-pixels in the bitmaps.
<p> 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.
<p> <p>See also <a href="qbitmap.html#QBitmap">QBitmap::QBitmap</a>() and <a href="qpixmap.html#setMask">QBitmap::setMask</a>().
<h3 class=fn><a name="QCursor-4"></a>QCursor::QCursor ( const <a href="qpixmap.html">QPixmap</a> & pixmap, int hotX = -1, int hotY = -1 )
</h3>
Constructs a custom pixmap cursor.
<p> <em>pixmap</em> is the image. It is usual to give it a mask (set using
<a href="qpixmap.html#setMask">QPixmap::setMask</a>()). <em>hotX</em> and <em>hotY</em> define the cursor's hot
spot.
<p> If <em>hotX</em> is negative, it is set to the <tt>pixmap().width()/2</tt>.
If <em>hotY</em> is negative, it is set to the <tt>pixmap().height()/2</tt>.
<p> 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.
<p> Currently, only black-and-white pixmaps can be used.
<p> <p>See also <a href="qpixmap.html#QPixmap">QPixmap::QPixmap</a>() and <a href="qpixmap.html#setMask">QPixmap::setMask</a>().
<h3 class=fn><a name="QCursor-5"></a>QCursor::QCursor ( const <a href="qcursor.html">QCursor</a> & c )
</h3>
Constructs a copy of the cursor <em>c</em>.
<h3 class=fn><a name="QCursor-6"></a>QCursor::QCursor ( HCURSOR handle )
</h3>
<p> Creates a cursor with the specified window system handle <em>handle</em>.
<p> <b>Warning:</b>
Portable in principle, but if you use it you are probably about to
do something non-portable. Be careful.
<h3 class=fn><a name="~QCursor"></a>QCursor::~QCursor ()
</h3>
Destroys the cursor.
<h3 class=fn>const <a href="qbitmap.html">QBitmap</a> * <a name="bitmap"></a>QCursor::bitmap () const
</h3>
Returns the cursor bitmap, or 0 if it is one of the standard
cursors.
<h3 class=fn>void <a name="cleanup"></a>QCursor::cleanup ()<tt> [static]</tt>
</h3>
Internal function that deinitializes the predefined cursors.
This function is called from the <a href="qapplication.html">QApplication</a> destructor.
<p> <p>See also <a href="#initialize">initialize</a>().
<h3 class=fn>HANDLE <a name="handle"></a>QCursor::handle () const
</h3>
Returns the window system cursor handle.
<p> <b>Warning:</b>
Portable in principle, but if you use it you are probably about to
do something non-portable. Be careful.
<h3 class=fn><a href="qpoint.html">QPoint</a> <a name="hotSpot"></a>QCursor::hotSpot () const
</h3>
Returns the cursor hot spot, or (0, 0) if it is one of the
standard cursors.
<h3 class=fn>void <a name="initialize"></a>QCursor::initialize ()<tt> [static]</tt>
</h3>
Internal function that initializes the predefined cursors.
This function is called from the <a href="qapplication.html">QApplication</a> constructor.
<p> <p>See also <a href="#cleanup">cleanup</a>().
<h3 class=fn>const <a href="qbitmap.html">QBitmap</a> * <a name="mask"></a>QCursor::mask () const
</h3>
Returns the cursor bitmap mask, or 0 if it is one of the standard
cursors.
<h3 class=fn><a href="qcursor.html">QCursor</a> & <a name="operator-eq"></a>QCursor::operator= ( const <a href="qcursor.html">QCursor</a> & c )
</h3>
Assigns <em>c</em> to this cursor and returns a reference to this
cursor.
<h3 class=fn><a href="qpoint.html">QPoint</a> <a name="pos"></a>QCursor::pos ()<tt> [static]</tt>
</h3>
Returns the position of the cursor (hot spot) in global screen
coordinates.
<p> You can call <a href="qwidget.html#mapFromGlobal">QWidget::mapFromGlobal</a>() to translate it to widget
coordinates.
<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>().
<p>Examples: <a href="tutorial2-06.html#x2580">chart/canvasview.cpp</a>, <a href="fileiconview-example.html#x809">fileiconview/qfileiconview.cpp</a>, and <a href="menu-example.html#x1746">menu/menu.cpp</a>.
<h3 class=fn>void <a name="setPos"></a>QCursor::setPos ( int x, int y )<tt> [static]</tt>
</h3>
Moves the cursor (hot spot) to the global screen position (<em>x</em>,
<em>y</em>).
<p> You can call <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>() to translate widget
coordinates to global screen coordinates.
<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>().
<h3 class=fn>void <a name="setPos-2"></a>QCursor::setPos ( const <a href="qpoint.html">QPoint</a> & )<tt> [static]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p>
<h3 class=fn>void <a name="setShape"></a>QCursor::setShape ( int shape )
</h3>
Sets the cursor to the shape identified by <em>shape</em>.
<p> See <a href="qt.html#CursorShape-enum">CursorShape</a> for the list of cursor shapes.
<p> <p>See also <a href="#shape">shape</a>().
<h3 class=fn>int <a name="shape"></a>QCursor::shape () const
</h3>
Returns the cursor shape identifier. The return value is one of
the <a href="qt.html#CursorShape-enum">CursorShape</a> enum values (cast to an int).
<p> <p>See also <a href="#setShape">setShape</a>().
<hr><h2>Related Functions</h2>
<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 )
</h3>
Writes the cursor <em>c</em> to the stream <em>s</em>.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
<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 )
</h3>
Reads a cursor from the stream <em>s</em> and sets <em>c</em> to the read data.
<p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright © 1995-2005
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2005
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.7</div>
</table></div></address></body>
</html>
|