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
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QCursor Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QCursor Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QCursor class provides a mouse cursor with an arbitrary shape. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qcursor.html#QCursor">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcursor.html#QCursor-2">__init__</a></b> (<i>self</i>, Qt.CursorShape <i>shape</i>)</li><li><div class="fn" /><b><a href="qcursor.html#QCursor-3">__init__</a></b> (<i>self</i>, QBitmap <i>bitmap</i>, QBitmap <i>mask</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</li><li><div class="fn" /><b><a href="qcursor.html#QCursor-4">__init__</a></b> (<i>self</i>, QPixmap <i>pixmap</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</li><li><div class="fn" /><b><a href="qcursor.html#QCursor-5">__init__</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" /><b><a href="qcursor.html#QCursor-6">__init__</a></b> (<i>self</i>, QCursor <i>cursor</i>)</li><li><div class="fn" />QBitmap <b><a href="qcursor.html#bitmap">bitmap</a></b> (<i>self</i>)</li><li><div class="fn" />QPoint <b><a href="qcursor.html#hotSpot">hotSpot</a></b> (<i>self</i>)</li><li><div class="fn" />QBitmap <b><a href="qcursor.html#mask">mask</a></b> (<i>self</i>)</li><li><div class="fn" />QPixmap <b><a href="qcursor.html#pixmap">pixmap</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qcursor.html#setShape">setShape</a></b> (<i>self</i>, Qt.CursorShape <i>newShape</i>)</li><li><div class="fn" />Qt.CursorShape <b><a href="qcursor.html#shape">shape</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QPoint <b><a href="qcursor.html#pos">pos</a></b> ()</li><li><div class="fn" /><b><a href="qcursor.html#setPos">setPos</a></b> (int <i>x</i>, int <i>y</i>)</li><li><div class="fn" /><b><a href="qcursor.html#setPos-2">setPos</a></b> (QPoint <i>p</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>A
<a href="qt.html#CursorShape-enum">Qt.CursorShape</a>
may be used whenever a
<a href="qcursor.html">QCursor</a>
is expected.</p>
<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>
<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>
<p>To associate a cursor with a widget, use <a href="qwidget.html#cursor-prop">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>
<p>To set a cursor shape use <a href="qcursor.html#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">Qt.CursorShape</a> enum.</p>
<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>
<p>To set or get the position of the mouse cursor use the static methods <a href="qcursor.html#pos">QCursor.pos</a>() and <a href="qcursor.html#setPos">QCursor.setPos</a>().</p>
<p align="center"><img alt="Cursor Shapes" src="images/cursors.png" /></p>
<a id="a-note-for-x11-users" name="a-note-for-x11-users" />
<h3>A Note for X11 Users</h3>
<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 <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> 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 <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> values. It is possible that some cursors will be taken from the Xcursor theme, while others will use an internal bitmap cursor.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#A2C511" valign="top">
<th><a href="qt.html#CursorShape-enum">Qt.CursorShape</a> Values</th>
<th>Cursor Names</th>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.ArrowCursor</a></td>
<td><tt>left_ptr</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.UpArrowCursor</a></td>
<td><tt>up_arrow</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.CrossCursor</a></td>
<td><tt>cross</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.WaitCursor</a></td>
<td><tt>wait</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.BusyCursor</a></td>
<td><tt>left_ptr_watch</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.IBeamCursor</a></td>
<td><tt>ibeam</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SizeVerCursor</a></td>
<td><tt>size_ver</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SizeHorCursor</a></td>
<td><tt>size_hor</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SizeBDiagCursor</a></td>
<td><tt>size_bdiag</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SizeFDiagCursor</a></td>
<td><tt>size_fdiag</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SizeAllCursor</a></td>
<td><tt>size_all</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SplitVCursor</a></td>
<td><tt>split_v</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.SplitHCursor</a></td>
<td><tt>split_h</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.PointingHandCursor</a></td>
<td><tt>pointing_hand</tt></td>
</tr>
<tr bgcolor="#F0F0F0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.ForbiddenCursor</a></td>
<td><tt>forbidden</tt></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qt.html#CursorShape-enum">Qt.WhatsThisCursor</a></td>
<td><tt>whats_this</tt></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qwidget.html">QWidget</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Cursors</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QCursor" />QCursor.__init__ (<i>self</i>)</h3><p>Constructs a cursor with the default arrow shape.</p>
<h3 class="fn"><a name="QCursor-2" />QCursor.__init__ (<i>self</i>, <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> <i>shape</i>)</h3><p>Constructs a cursor with the specified <i>shape</i>.</p>
<p>See <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> for a list of shapes.</p>
<p>See also <a href="qcursor.html#setShape">setShape</a>().</p>
<h3 class="fn"><a name="QCursor-3" />QCursor.__init__ (<i>self</i>, <a href="qbitmap.html">QBitmap</a> <i>bitmap</i>, <a href="qbitmap.html">QBitmap</a> <i>mask</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</h3><p>Constructs a custom bitmap cursor.</p>
<p><i>bitmap</i> and <i>mask</i> make up the bitmap. <i>hotX</i> and <i>hotY</i> define the cursor's hot spot.</p>
<p>If <i>hotX</i> is negative, it is set to the <tt>bitmap().width()/2</tt>. If <i>hotY</i> is negative, it is set to the <tt>bitmap().height()/2</tt>.</p>
<p>The cursor <i>bitmap</i> (B) and <i>mask</i> (M) bits are combined like this:</p>
<ul>
<li>B=1 and M=1 gives black.</li>
<li>B=0 and M=1 gives white.</li>
<li>B=0 and M=0 gives transparent.</li>
<li>B=1 and M=0 gives an XOR'd result.</li>
</ul>
<p>Use the global Qt color <a href="qt.html#GlobalColor-enum">Qt.color0</a> to draw 0-pixels and <a href="qt.html#GlobalColor-enum">Qt.color1</a> to draw 1-pixels in the bitmaps.</p>
<p>Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32 x 32 cursors, because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors.</p>
<p>See also <a href="qbitmap.html#QBitmap">QBitmap.QBitmap</a>() and <a href="qpixmap.html#setMask">QBitmap.setMask</a>().</p>
<h3 class="fn"><a name="QCursor-4" />QCursor.__init__ (<i>self</i>, <a href="qpixmap.html">QPixmap</a> <i>pixmap</i>, int <i>hotX</i> = -1, int <i>hotY</i> = -1)</h3><p>Constructs a custom pixmap cursor.</p>
<p><i>pixmap</i> is the image. It is usual to give it a mask (set using <a href="qpixmap.html#setMask">QPixmap.setMask</a>()). <i>hotX</i> and <i>hotY</i> define the cursor's hot spot.</p>
<p>If <i>hotX</i> is negative, it is set to the <tt>pixmap().width()/2</tt>. If <i>hotY</i> is negative, it is set to the <tt>pixmap().height()/2</tt>.</p>
<p>Valid cursor sizes depend on the display hardware (or the underlying window system). We recommend using 32 x 32 cursors, because this size is supported on all platforms. Some platforms also support 16 x 16, 48 x 48, and 64 x 64 cursors.</p>
<p>See also <a href="qpixmap.html#QPixmap">QPixmap.QPixmap</a>() and <a href="qpixmap.html#setMask">QPixmap.setMask</a>().</p>
<h3 class="fn"><a name="QCursor-5" />QCursor.__init__ (<i>self</i>, <a href="qvariant.html">QVariant</a>)</h3><p>Constructs a copy of the cursor <i>c</i>.</p>
<h3 class="fn"><a name="QCursor-6" />QCursor.__init__ (<i>self</i>, <a href="qcursor.html">QCursor</a> <i>cursor</i>)</h3><p>Constructs a Qt cursor from the given Windows <i>cursor</i>.</p>
<p><b>Warning:</b> This function is only available on Windows.</p>
<p>See also <a href="qcursor.html#handle">handle</a>().</p>
<h3 class="fn"><a name="bitmap" /><a href="qbitmap.html">QBitmap</a> QCursor.bitmap (<i>self</i>)</h3><p>Returns the cursor bitmap, or 0 if it is one of the standard cursors.</p>
<h3 class="fn"><a name="hotSpot" /><a href="qpoint.html">QPoint</a> QCursor.hotSpot (<i>self</i>)</h3><p>Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.</p>
<h3 class="fn"><a name="mask" /><a href="qbitmap.html">QBitmap</a> QCursor.mask (<i>self</i>)</h3><p>Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.</p>
<h3 class="fn"><a name="pixmap" /><a href="qpixmap.html">QPixmap</a> QCursor.pixmap (<i>self</i>)</h3><p>Returns the cursor pixmap. This is only valid if the cursor is a pixmap cursor.</p>
<h3 class="fn"><a name="pos" /><a href="qpoint.html">QPoint</a> QCursor.pos ()</h3><p>Returns the position of the cursor (hot spot) in global screen coordinates.</p>
<p>You can call <a href="qwidget.html#mapFromGlobal">QWidget.mapFromGlobal</a>() to translate it to widget coordinates.</p>
<p>See also <a href="qcursor.html#setPos">setPos</a>(), <a href="qwidget.html#mapFromGlobal">QWidget.mapFromGlobal</a>(), and <a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>
<h3 class="fn"><a name="setPos" />QCursor.setPos (int <i>x</i>, int <i>y</i>)</h3><p>Moves the cursor (hot spot) to the global screen position (<i>x</i>, <i>y</i>).</p>
<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="qcursor.html#pos">pos</a>(), <a href="qwidget.html#mapFromGlobal">QWidget.mapFromGlobal</a>(), and <a href="qwidget.html#mapToGlobal">QWidget.mapToGlobal</a>().</p>
<h3 class="fn"><a name="setPos-2" />QCursor.setPos (<a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Moves the cursor (hot spot) to the global screen position at point <i>p</i>.</p>
<h3 class="fn"><a name="setShape" />QCursor.setShape (<i>self</i>, <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> <i>newShape</i>)</h3><p>Sets the cursor to the shape identified by <i>shape</i>.</p>
<p>See <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> for the list of cursor shapes.</p>
<p>See also <a href="qcursor.html#shape">shape</a>().</p>
<h3 class="fn"><a name="shape" /><a href="qt.html#CursorShape-enum">Qt.CursorShape</a> QCursor.shape (<i>self</i>)</h3><p>Returns the cursor shape identifier. The return value is one of the <a href="qt.html#CursorShape-enum">Qt.CursorShape</a> enum values (cast to an int).</p>
<p>See also <a href="qcursor.html#setShape">setShape</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|