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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QCursor Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QCursor Class Reference</h1><br clear="all">
<p>
The QCursor class provides a mouse cursor with an arbitrary shape.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qcursor-h.html">qcursor.h</a>></code>
<p><a href="qcursor-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#cb794b"><b>QCursor</b></a>()</div>
<li><div class="fn"><a href="#58d6c9"><b>QCursor</b></a>(intshape)</div>
<li><div class="fn"><a href="#feb07e"><b>QCursor</b></a>(constQBitmap&bitmap, constQBitmap&mask, inthotX=-1, inthotY=-1)</div>
<li><div class="fn"><a href="#ae3466"><b>QCursor</b></a>(constQPixmap&pixmap, inthotX=-1, inthotY=-1)</div>
<li><div class="fn"><a href="#cd8027"><b>QCursor</b></a>(constQCursor&)</div>
<li><div class="fn"><a href="#edabc1"><b>~QCursor</b></a>()</div>
<li><div class="fn">QCursor&<a href="#e72e88"><b>operator=</b></a>(constQCursor&)</div>
<li><div class="fn">int<a href="#90d24d"><b>shape</b></a>()const</div>
<li><div class="fn">void<a href="#645175"><b>setShape</b></a>(int)</div>
<li><div class="fn">constQBitmap*<a href="#bf6796"><b>bitmap</b></a>()const</div>
<li><div class="fn">constQBitmap*<a href="#43edee"><b>mask</b></a>()const</div>
<li><div class="fn">QPoint<a href="#ccd825"><b>hotSpot</b></a>()const</div>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><div class="fn">QPoint<a href="#5bce2b"><b>pos</b></a>()</div>
<li><div class="fn">void<a href="#a1419a"><b>setPos</b></a>(intx, inty)</div>
<li><div class="fn">void<a href="#ac0105"><b>setPos</b></a>(constQPoint&)</div>
<li><div class="fn">void<a href="#b8730c"><b>initialize</b></a>()</div>
<li><div class="fn">void<a href="#e4715a"><b>cleanup</b></a>()</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qcursor.html#5ce298"><b>operator>></b></a> (QDataStream & s, QCursor & c)
<li>QDataStream & <a href="qcursor.html#7d05a5"><b>operator<<</b></a> (QDataStream & s, const QCursor & c)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QCursor class provides a mouse cursor with an arbitrary shape.
<p>
This class is used for mainly two things; to create mouse cursors to be
associated with 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#9b6e22">QWidget::setCursor</a>(). To
associate a cursor with all widgets (normally for a short period of
time), use <a href="qapplication.html#07e1f1">QApplication::setOverrideCursor</a>().
<p>To set a cursor shape use <a href="#645175">QCursor::setShape</a>() or use the QCursor constructor
which takes the shape as argument, or use one of the <em>predefined</em> cursors:
<p><ul>
<li> <code>arrowCursor</code> - standard arrow cursor
<li> <code>upArrowCursor</code> - upwards arrow
<li> <code>crossCursor</code> - crosshair
<li> <code>waitCursor</code> - hourglass/watch
<li> <code>ibeamCursor</code> - ibeam/text entry
<li> <code>sizeVerCursor</code> - vertical resize
<li> <code>sizeHorCursor</code> - horizontal resize
<li> <code>sizeBDiagCursor</code> - diagonal resize (/)
<li> <code>sizeFDiagCursor</code> - diagonal resize (\)
<li> <code>sizeAllCursor</code> - all directions resize
<li> <code>blankCursor</code> - blank/invisible cursor
<li> <code>splitVCursor</code> - vertical splitting
<li> <code>splitHCursor</code> - horziontal splitting
<li> <code>pointingHandCursor</code> - a pointing hand
<li> <code>forbiddenCursor</code> - a slashed circle
</ul>
<p>If you want to create a cursor with an own bitmap, use either the QCursor
constructor which takes a 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="#5bce2b">QCursor::pos</a>() and <a href="#a1419a">QCursor::setPos</a>().
<p>See also <a href="qwidget.html">QWidget</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Cursors.</a>
<p>Examples:
<a href="cursor-cursor-cpp.html#QCursor">cursor/cursor.cpp</a>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="cb794b"></a>QCursor::QCursor()</h3>
<p>Constructs a cursor with the default arrow shape.
<h3 class="fn"><a name="feb07e"></a>QCursor::QCursor(const<a href="qbitmap.html">QBitmap</a>&bitmap, const<a href="qbitmap.html">QBitmap</a>&mask, inthotX=-1, inthotY=-1)</h3>
<p>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 hot spot of this cursor.
<p>If <em>hotX</em> is negative, it is set to the <a href="#bf6796">bitmap</a>().width()/2.
If <em>hotY</em> is negative, it is set to the bitmap().height()/2.
<p>The cursor <em>bitmap</em> (B) and <em>mask</em> (M) bits are combined this way:
<ol>
<li> B=1 and M=1 gives black.
<li> B=0 and M=1 gives white.
<li> B=0 and M=0 gives transparency.
<li> B=1 and M=0 gives an undefined result.
</ol>
<p>Use the global color <code>color0</code> to draw 0-pixels and <code>color1</code> to draw
1-pixels in the bitmaps.
<p>Allowed 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>See also <a href="qbitmap.html#12bed2">QBitmap::QBitmap</a>() and <a href="qpixmap.html#68a75d">QBitmap::setMask</a>().
<h3 class="fn"><a name="ae3466"></a>QCursor::QCursor(const<a href="qpixmap.html">QPixmap</a>&pixmap, inthotX=-1, inthotY=-1)</h3>
<p>Constructs a custom pixmap cursor.
<p><em>pixmap</em> is the image
(usually it should have a mask (set using <a href="qpixmap.html#68a75d">QPixmap::setMask</a>())
<em>hotX</em> and
<em>hotY</em> define the hot spot of this cursor.
<p>If <em>hotX</em> is negative, it is set to the pixmap().width()/2.
If <em>hotY</em> is negative, it is set to the pixmap().height()/2.
<p>Allowed 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>See also <a href="qpixmap.html#0b95b1">QPixmap::QPixmap</a>() and <a href="qpixmap.html#68a75d">QPixmap::setMask</a>().
<h3 class="fn"><a name="cd8027"></a>QCursor::QCursor(constQCursor&c)</h3>
<p>Constructs a copy of the cursor <em>c.</em>
<h3 class="fn"><a name="58d6c9"></a>QCursor::QCursor(intshape)</h3>
<p>Constructs a cursor with the specified <em>shape.</em>
<p><em>shape</em> can be one of
<ul>
<li> <code>ArrowCursor</code> - standard arrow cursor
<li> <code>UpArrowCursor</code> - upwards arrow
<li> <code>CrossCursor</code> - crosshair
<li> <code>WaitCursor</code> - hourglass/watch
<li> <code>IbeamCursor</code> - ibeam/text entry
<li> <code>SizeVerCursor</code> - vertical resize
<li> <code>SizeHorCursor</code> - horizontal resize
<li> <code>SizeBDiagCursor</code> - diagonal resize (/)
<li> <code>SizeFDiagCursor</code> - diagonal resize (\)
<li> <code>SizeAllCursor</code> - all directions resize
<li> <code>BlankCursor</code> - blank/invisible cursor
<li> <code>SplitVCursor</code> - vertical splitting
<li> <code>SplitHCursor</code> - horziontal splitting
<li> <code>PointingHandCursor</code> - a pointing hand
<li> <code>BitmapCursor</code> - userdefined bitmap cursor
</ul>
<p>These correspond to the <a href="#cursors">predefined</a>
global QCursor objects.
<p>See also <a href="#645175">setShape</a>().
<h3 class="fn"><a name="edabc1"></a>QCursor::~QCursor()</h3>
<p>Destructs the cursor.
<h3 class="fn">const<a href="qbitmap.html">QBitmap</a>*<a name="bf6796"></a>QCursor::bitmap()const</h3>
<p>Returns the cursor bitmap, or 0 if it is one of the standard cursors.
<h3 class="fn">void<a name="e4715a"></a>QCursor::cleanup() <code>[static]</code></h3>
<p>Internal function that deinitializes the predefined cursors.
This function is called from the <a href="qapplication.html">QApplication</a> destructor.
<p>See also <a href="#b8730c">initialize</a>().
<h3 class="fn"><a href="qpoint.html">QPoint</a><a name="ccd825"></a>QCursor::hotSpot()const</h3>
<p>Returns the cursor hot spot, or (0,0) if it is one of the standard cursors.
<h3 class="fn">void<a name="b8730c"></a>QCursor::initialize() <code>[static]</code></h3>
<p>Internal function that initializes the predefined cursors.
This function is called from the <a href="qapplication.html">QApplication</a> constructor.
<p>See also <a href="#e4715a">cleanup</a>().
<h3 class="fn">const<a href="qbitmap.html">QBitmap</a>*<a name="43edee"></a>QCursor::mask()const</h3>
<p>Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.
<h3 class="fn">QCursor&<a name="e72e88"></a>QCursor::operator=(constQCursor&c)</h3>
<p>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="5bce2b"></a>QCursor::pos() <code>[static]</code></h3>
<p>Returns the position of the cursor (hot spot) in global screen
coordinates.
<p>You can call <a href="qwidget.html#cb3348">QWidget::mapFromGlobal</a>() to translate it to widget
coordinates.
<p>See also <a href="#a1419a">setPos</a>(), <a href="qwidget.html#cb3348">QWidget::mapFromGlobal</a>() and <a href="qwidget.html#eb4b9c">QWidget::mapToGlobal</a>().
<h3 class="fn">void<a name="a1419a"></a>QCursor::setPos(intx, inty) <code>[static]</code></h3>
<p>Moves the cursor (hot spot) to the global screen position <em>x</em> and <em>y.</em>
<p>You can call <a href="qwidget.html#eb4b9c">QWidget::mapToGlobal</a>() to translate widget coordinates
to global screen coordinates.
<p>See also <a href="#5bce2b">pos</a>(), <a href="qwidget.html#cb3348">QWidget::mapFromGlobal</a>() and <a href="qwidget.html#eb4b9c">QWidget::mapToGlobal</a>().
<h3 class="fn">void<a name="ac0105"></a>QCursor::setPos(const<a href="qpoint.html">QPoint</a>&) <code>[static]</code></h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<h3 class="fn">void<a name="645175"></a>QCursor::setShape(intshape)</h3>
<p>Sets the cursor to the shape identified by <em>shape.</em>
<p><ul>
<li> <code>ArrowCursor</code> - standard arrow cursor
<li> <code>UpArrowCursor</code> - upwards arrow
<li> CrossCursor - crosshair
<li> <code>WaitCursor</code> - hourglass/watch
<li> <code>IbeamCursor</code> - ibeam/text entry
<li> <code>SizeVerCursor</code> - vertical resize
<li> <code>SizeHorCursor</code> - horizontal resize
<li> <code>SizeBDiagCursor</code> - diagonal resize (/)
<li> <code>SizeFDiagCursor</code> - diagonal resize (\)
<li> <code>SizeAllCursor</code> - all directions resize
<li> <code>BlankCursor</code> - blank/invisible cursor
<li> <code>SplitVCursor</code> - vertical splitting
<li> <code>SplitHCursor</code> - horziontal splitting
<li> <code>PointingHandCursor</code> - a pointing hand
<li> <code>ForbiddenCursor</code> - a slashed circle
<li> <code>BitmapCursor</code> - userdefined bitmap cursor
</ul>
<p>These correspond to the <a href="#cursors">predefined</a>
global QCursor objects.
<p>See also <a href="#90d24d">shape</a>().
<h3 class="fn">int<a name="90d24d"></a>QCursor::shape()const</h3>
<p>Returns the cursor shape identifer. The return value is one of
following values (cast to an int)
<p><ul>
<li> <code>ArrowCursor</code> - standard arrow cursor
<li> <code>UpArrowCursor</code> - upwards arrow
<li> <code>CrossCursor</code> - crosshair
<li> <code>WaitCursor</code> - hourglass/watch
<li> <code>IbeamCursor</code> - ibeam/text entry
<li> <code>SizeVerCursor</code> - vertical resize
<li> <code>SizeHorCursor</code> - horizontal resize
<li> <code>SizeBDiagCursor</code> - diagonal resize (/)
<li> <code>SizeFDiagCursor</code> - diagonal resize (\)
<li> <code>SizeAllCursor</code> - all directions resize
<li> <code>BlankCursor</code> - blank/invisible cursor
<li> <code>SplitVCursor</code> - vertical splitting
<li> <code>SplitHCursor</code> - horziontal splitting
<li> <code>PointingHandCursor</code> - a pointing hand
<li> <code>ForbiddenCursor</code> - a slashed circle
<li> <code>BitmapCursor</code> - userdefined bitmap cursor
</ul>
<p>These correspond to the <a href="#cursors">predefined</a>
global QCursor objects.
<p>See also <a href="#645175">setShape</a>().
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="5ce298"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QCursor & c)</h3>
<p>Reads a cursor from the stream <em>s</em> and sets <em>c</em> to the read data.
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="7d05a5"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QCursor & c)</h3>
<p>Writes the cursor <em>c</em> to the stream <em>s.</em>
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<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 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|