<class name="QCursor" doc="/** <p>The <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> 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"><tt>QBitmap</tt></a>, a mask and a hotspot.</p> <p>To associate a cursor with a widget, use QWidget::setCursor(). To associate a cursor with all widgets (normally for a short period of time), use QApplication::setOverrideCursor().</p> <p>To set a cursor shape use QCursor::setShape() or use the <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the <tt>Qt::CursorShape</tt> enum.</p> <p>If you want to create a cursor with your own bitmap, either use the <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> 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 QCursor::pos() and QCursor::setPos().</p> <p><b>Note:</b> It is possible to create a <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> before <a href="QApplication.html"><tt>QApplication</tt></a>, but it is not useful except as a place-holder for a real <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> created after <a href="QApplication.html"><tt>QApplication</tt></a>. Attempting to use a <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a> that was created before <a href="QApplication.html"><tt>QApplication</tt></a> will result in a crash.</p> <a name="a-note-for-x11-users"></a> <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</tt></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> <p><table align="center" cellpadding="2" cellspacing="1" border="0"> <thead><tr valign="top" class="qt-style"><th>Shape</th><th>Qt::CursorShape Value</th><th>Cursor Name</th><th>Shape</th><th>Qt::CursorShape Value</th><th>Cursor Name</th></tr></thead> <tr valign="top" class="odd"><td><img src="%2E%2E/images/cursor-arrow.png" /></td><td>Qt::ArrowCursor</td><td><tt>left_ptr</tt></td><td><img src="%2E%2E/images/cursor-sizev.png" /></td><td>Qt::SizeVerCursor</td><td><tt>size_ver</tt></td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/cursor-uparrow.png" /></td><td>Qt::UpArrowCursor</td><td><tt>up_arrow</tt></td><td><img src="%2E%2E/images/cursor-sizeh.png" /></td><td>Qt::SizeHorCursor</td><td><tt>size_hor</tt></td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/cursor-cross.png" /></td><td>Qt::CrossCursor</td><td><tt>cross</tt></td><td><img src="%2E%2E/images/cursor-sizeb.png" /></td><td>Qt::SizeBDiagCursor</td><td><tt>size_bdiag</tt></td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/cursor-ibeam.png" /></td><td>Qt::IBeamCursor</td><td><tt>ibeam</tt></td><td><img src="%2E%2E/images/cursor-sizef.png" /></td><td>Qt::SizeFDiagCursor</td><td><tt>size_fdiag</tt></td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/cursor-wait.png" /></td><td>Qt::WaitCursor</td><td><tt>wait</tt></td><td><img src="%2E%2E/images/cursor-sizeall.png" /></td><td>Qt::SizeAllCursor</td><td><tt>size_all</tt></td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/cursor-busy.png" /></td><td>Qt::BusyCursor</td><td><tt>left_ptr_watch</tt></td><td><img src="%2E%2E/images/cursor-vsplit.png" /></td><td>Qt::SplitVCursor</td><td><tt>split_v</tt></td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/cursor-forbidden.png" /></td><td>Qt::ForbiddenCursor</td><td><tt>forbidden</tt></td><td><img src="%2E%2E/images/cursor-hsplit.png" /></td><td>Qt::SplitHCursor</td><td><tt>split_h</tt></td></tr> <tr valign="top" class="even"><td><img src="%2E%2E/images/cursor-hand.png" /></td><td>Qt::PointingHandCursor</td><td><tt>pointing_hand</tt></td><td><img src="%2E%2E/images/cursor-openhand.png" /></td><td>Qt::OpenHandCursor</td><td><tt>openhand</tt></td></tr> <tr valign="top" class="odd"><td><img src="%2E%2E/images/cursor-whatsthis.png" /></td><td>Qt::WhatsThisCursor</td><td><tt>whats_this</tt></td><td><img src="%2E%2E/images/cursor-closedhand.png" /></td><td>Qt::ClosedHandCursor</td><td><tt>closedhand</tt></td></tr> </table></p> @see <a href="QWidget.html"><tt>QWidget</tt></a> @see <a href="%2E%2E/guibooks.html#fowler">GUI Design Handbook: Cursors</tt></a> */"> <method name="public QCursor()" doc="/** <p>Constructs a cursor with the default arrow shape.</p> */"/> <method name="public QCursor(com.trolltech.qt.core.Qt.CursorShape shape)" doc="/** <p>Constructs a cursor with the specified <tt>shape</tt>.</p> <p>See <tt>Qt::CursorShape</tt> for a list of shapes.</p> @see <a href="QCursor.html#setShape(com.trolltech.qt.core.Qt.CursorShape)"><tt>setShape</tt></a> */"/> <method name="public QCursor(com.trolltech.qt.gui.QBitmap bitmap, com.trolltech.qt.gui.QBitmap mask, int hotX, int hotY)" doc="/** <p>Constructs a custom bitmap cursor.</p> <p><tt>bitmap</tt> and <tt>mask</tt> make up the bitmap. <tt>hotX</tt> and <tt>hotY</tt> define the cursor's hot spot.</p> <p>If <tt>hotX</tt> is negative, it is set to the <tt>bitmap().width()/2</tt>. If <tt>hotY</tt> is negative, it is set to the <tt>bitmap().height()/2</tt>.</p> <p>The cursor <tt>bitmap</tt> (B) and <tt>mask</tt> (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 Qt::color0 to draw 0-pixels and Qt::color1 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> @see <tt>QBitmap::QBitmap</tt> @see <tt>QBitmap::setMask</tt> */"/> <method name="public QCursor(com.trolltech.qt.gui.QBitmap bitmap, com.trolltech.qt.gui.QBitmap mask, int hotX)" doc="/** <p>Equivalent to <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a>(<tt>bitmap</tt>, <tt>mask</tt>, <tt>hotX</tt>, -1). */"/> <method name="public QCursor(com.trolltech.qt.gui.QBitmap bitmap, com.trolltech.qt.gui.QBitmap mask)" doc="/** <p>Equivalent to <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a>(<tt>bitmap</tt>, <tt>mask</tt>, -1, -1). */"/> <method name="public QCursor(com.trolltech.qt.gui.QCursor cursor)" doc="/** <p>Constructs a copy of the cursor <tt>cursor</tt>.</p> */"/> <method name="public QCursor(com.trolltech.qt.gui.QPixmap pixmap, int hotX, int hotY)" doc="/** <p>Constructs a custom pixmap cursor.</p> <p><tt>pixmap</tt> is the image. It is usual to give it a mask (set using QPixmap::setMask()). <tt>hotX</tt> and <tt>hotY</tt> define the cursor's hot spot.</p> <p>If <tt>hotX</tt> is negative, it is set to the <tt>pixmap().width()/2</tt>. If <tt>hotY</tt> 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> @see <tt>QPixmap::QPixmap</tt> @see <tt>QPixmap::setMask</tt> */"/> <method name="public QCursor(com.trolltech.qt.gui.QPixmap pixmap, int hotX)" doc="/** <p>Equivalent to <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a>(<tt>pixmap</tt>, <tt>hotX</tt>, -1). */"/> <method name="public QCursor(com.trolltech.qt.gui.QPixmap pixmap)" doc="/** <p>Equivalent to <a href="QCursor.html#QCursor(com.trolltech.qt.gui.QPixmap, int, int)"><tt>QCursor</tt></a>(<tt>pixmap</tt>, -1, -1). */"/> <method name="public final com.trolltech.qt.core.QPoint hotSpot()" doc="/** <p>Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.</p> */"/> <method name="public final void writeTo(com.trolltech.qt.core.QDataStream outS)"/> <method name="public final void readFrom(com.trolltech.qt.core.QDataStream inS)"/> <method name="public final com.trolltech.qt.gui.QPixmap pixmap()" doc="/** <p>Returns the cursor pixmap. This is only valid if the cursor is a pixmap cursor.</p> */"/> <method name="public final void setShape(com.trolltech.qt.core.Qt.CursorShape newShape)" doc="/** <p>Sets the cursor to the shape identified by <tt>newShape</tt>.</p> <p>See <tt>Qt::CursorShape</tt> for the list of cursor shapes.</p> @see <a href="QCursor.html#shape()"><tt>shape</tt></a> */"/> <method name="public final com.trolltech.qt.core.Qt.CursorShape shape()" doc="/** <p>Returns the cursor shape identifier. The return value is one of the <tt>Qt::CursorShape</tt> enum values (cast to an int).</p> @see <a href="QCursor.html#setShape(com.trolltech.qt.core.Qt.CursorShape)"><tt>setShape</tt></a> */"/> <method name="public native static com.trolltech.qt.core.QPoint pos()" doc="/** <p>Returns the position of the cursor (hot spot) in global screen coordinates.</p> <p>You can call QWidget::mapFromGlobal() to translate it to widget coordinates.</p> @see <a href="QCursor.html#setPos(int, int)"><tt>setPos</tt></a> @see <tt>QWidget::mapFromGlobal</tt> @see <tt>QWidget::mapToGlobal</tt> */"/> <method name="public static void setPos(com.trolltech.qt.core.QPoint p)" doc="/** <p>Moves the cursor (hot spot) to the global screen position at point <tt>p</tt>.</p> */"/> <method name="public native static void setPos(int x, int y)" doc="/** <p>Moves the cursor (hot spot) to the global screen position (<tt>x</tt>, <tt>y</tt>).</p> <p>You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.</p> @see <a href="QCursor.html#pos()"><tt>pos</tt></a> @see <tt>QWidget::mapFromGlobal</tt> @see <tt>QWidget::mapToGlobal</tt> */"/> </class>