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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta name="robots" content="noindex,noarchive">
<title>Qt Toolkit - QCursor Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 15%; text-indent: -15%; }
a:link { text-decoration: none; }
--></style>
</head><body bgcolor="#ffffff">
<a href=index.html><img width=122 height=65 src=qtlogo.jpg alt="Qt logo" align=left border=0></a>
<center><img src=dochead.gif width=472 height=27></center>
<br clear=all>
<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><span class="fn"><a href="qcursor.html#a0"><strong>QCursor</strong></a>()</span>
<li><span class="fn"><a href="qcursor.html#a1"><strong>QCursor</strong></a>(intshape)</span>
<li><span class="fn"><a href="qcursor.html#a2"><strong>QCursor</strong></a>(constQBitmap&bitmap, constQBitmap&mask, inthotX=-1, inthotY=-1)</span>
<li><span class="fn"><a href="qcursor.html#a3"><strong>QCursor</strong></a>(constQCursor&)</span>
<li><span class="fn"><a href="qcursor.html#a4"><strong>~QCursor</strong></a>()</span>
<li><span class="fn">QCursor&<a href="qcursor.html#a5"><strong>operator=</strong></a>(constQCursor&)</span>
<li><span class="fn">int<a href="qcursor.html#a6"><strong>shape</strong></a>()const</span>
<li><span class="fn">void<a href="qcursor.html#a7"><strong>setShape</strong></a>(int)</span>
<li><span class="fn">constQBitmap*<a href="qcursor.html#a8"><strong>bitmap</strong></a>()const</span>
<li><span class="fn">constQBitmap*<a href="qcursor.html#a9"><strong>mask</strong></a>()const</span>
<li><span class="fn">QPoint<a href="qcursor.html#b0"><strong>hotSpot</strong></a>()const</span>
<li><span class="fn">HANDLE<a href="qcursor.html#b1"><strong>handle</strong></a>()const</span>
</ul>
<h2>Static Public Members</h2>
<ul>
<li><span class="fn">QPoint<a href="qcursor.html#c2"><strong>pos</strong></a>()</span>
<li><span class="fn">void<a href="qcursor.html#c3"><strong>setPos</strong></a>(intx, inty)</span>
<li><span class="fn">void<a href="qcursor.html#c4"><strong>setPos</strong></a>(constQPoint&)</span>
<li><span class="fn">void<a href="qcursor.html#c0"><strong>initialize</strong></a>()</span>
<li><span class="fn">void<a href="qcursor.html#c1"><strong>cleanup</strong></a>()</span>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream & <a href="qcursor.html#b8"><strong>operator<<</strong></a> (QDataStream & s, const QCursor & c)
<li>QDataStream & <a href="qcursor.html#b9"><strong>operator>></strong></a> (QDataStream & s, 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">bitmap</a>, a
mask and a hotspot.
<p>To associate a cursor with a widget, use <a href="qwidget.html#g7">QWidget::setCursor</a>().
To associate a cursor with all widgets (maybe for a short period of time),
use <a href="qapplication.html#h6">QApplication::setOverrideCursor</a>().
<p>The <a name=cursors>predefined cursor</a> objects are:
<ul>
<li> arrowCursor : standard arrow cursor
<li> upArrowCursor : upwards arrow
<li> crossCursor : crosshair
<li> waitCursor : hourglass/watch
<li> ibeamCursor : ibeam/text entry
<li> sizeVerCursor : vertical resize
<li> sizeHorCursor : horizontal resize
<li> sizeBDiagCursor : diagonal resize (/)
<li> sizeFDiagCursor : diagonal resize (\)
<li> sizeAllCursor : all directions resize
<li> blankCursor : blank/invisible cursor
</ul>
<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="a0"></a>QCursor::QCursor()</h3>
<p>Constructs a cursor with the default arrow shape.
<h3 class="fn"><a name="a2"></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>Arguments:
<ul>
<li><em>bitmap</em> and
<li><em>mask</em> make up the bitmap.
<li><em>hotX</em> and
<li><em>hotY</em> define the hot spot of this cursor.
</ul>
If <em>hotX</em> is negative, it is set to the <a href="qcursor.html#a8">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.
<h3 class="fn"><a name="a3"></a>QCursor::QCursor(constQCursor&c)</h3>
<p>Constructs a copy of the cursor <em>c.</em>
<h3 class="fn"><a name="a1"></a>QCursor::QCursor(intshape)</h3>
<p>Constructs a cursor with the specified <em>shape.</em>
<h3 class="fn"><a name="a4"></a>QCursor::~QCursor()</h3>
<p>Destroys the cursor.
<h3 class="fn">const<a href="qbitmap.html">QBitmap</a>*<a name="a8"></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="c1"></a>QCursor::cleanup() <code>[static]</code></h3>
<p>Internal function that cleans up the predefined cursors.
This function is called from the <a href="qapplication.html">QApplication</a> destructor.
<p>See also: <a href="qcursor.html#c0">initialize</a>().
<h3 class="fn">HANDLE<a name="b1"></a>QCursor::handle()const</h3>
<p>Returns the window system cursor handle.<p><strong>Warning:</strong> 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="b0"></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="c0"></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="qcursor.html#c1">cleanup</a>().
<h3 class="fn">const<a href="qbitmap.html">QBitmap</a>*<a name="a9"></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="a5"></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="c2"></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#e4">QWidget::mapFromGlobal</a>() to translate it to widget
coordinates.
<p>See also: <a href="qcursor.html#c3">setPos</a>(), <a href="qwidget.html#e4">QWidget::mapFromGlobal</a>() and <a href="qwidget.html#e3">QWidget::mapToGlobal</a>().
<h3 class="fn">void<a name="c3"></a>QCursor::setPos(intx, inty) <code>[static]</code></h3>
<p>Moves the cursor (hot spot) to the global screen position <em>(x,y).</em>
<p>You can call <a href="qwidget.html#e3">QWidget::mapToGlobal</a>() to translate widget coordinates
to global screen coordinates.
<p>See also: <a href="qcursor.html#c2">pos</a>(), <a href="qwidget.html#e4">QWidget::mapFromGlobal</a>() and <a href="qwidget.html#e3">QWidget::mapToGlobal</a>().
<h3 class="fn">void<a name="c4"></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="a7"></a>QCursor::setShape(intshape)</h3>
<p>Sets the cursor to the shape identified by <em>shape.</em>
<p>The allowed shapes are: <code>ArrowCursor, UpArrowCursor, CrossCursor, WaitCursor, IbeamCursor, SizeVerCursor, SizeHorCursor, SizeBDiagCursor, SizeFDiagCursor, SizeAllCursor, BlankCursor.</code> These correspond to the <a
href="#cursors">predefined</a> global QCursor objects.
<p>See also: <a href="qcursor.html#a6">shape</a>().
<h3 class="fn">int<a name="a6"></a>QCursor::shape()const</h3>
<p>Returns the cursor shape identifer. If a custom bitmap has been set,
<code>BitmapCursor</code> is returned.
<p>See also: <a href="qcursor.html#a7">setShape</a>().
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> & <a name="b8"></a>operator<< (<a href="qdatastream.html">QDataStream</a> & s, const QCursor & c)</h3>
<p>Writes a cursor to the stream.
<h3><a href="qdatastream.html">QDataStream</a> & <a name="b9"></a>operator>> (<a href="qdatastream.html">QDataStream</a> & s, QCursor & c)</h3>
<p>Reads a cursor from the stream.
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.troll.no">www.troll.no</a>):<br>
<form method=post action="http://www.troll.no/search.cgi">
<input type=hidden name="version" value="1.44"><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-99
<a href="troll.html">Troll Tech</a>, all rights reserved.
<p>
It was generated from the following files:
<ul>
<li>qcursor.h: 1998/08/25
<li>qcursor.cpp: 1998/07/03
</ul>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 1999 Troll Tech<td><a href="trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 1.45</div>
</table></div></address></body></html>
|