The QCursor class provides a mouse cursor with an arbitrary shape. 更多...
A Qt.CursorShape may be used whenever a QCursor is expected.
The QCursor class provides a mouse cursor with an arbitrary shape.
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.
Qt has a number of standard cursor shapes, but you can also make custom cursor shapes based on a QBitmap , a mask and a hotspot.
Widget 要关联光标,使用 QWidget.setCursor (). To associate a cursor with all widgets (normally for a short period of time), use QApplication.setOverrideCursor ().
要设置光标形状使用 QCursor.setShape () or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the Qt.CursorShape 枚举。
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.
To set or get the position of the mouse cursor use the static methods QCursor.pos () 和 QCursor.setPos ().
注意: 它是可能的创建 QCursor 先于 QApplication , but it is not useful except as a place-holder for a real QCursor created after QApplication . Attempting to use a QCursor that was created before QApplication 将导致崩溃。
在 X11,Qt 支持 Xcursor 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.
| 形状 | Qt.CursorShape 值 | 光标名称 | 形状 | Qt.CursorShape 值 | 光标名称 |
|---|---|---|---|---|---|
|
Qt.ArrowCursor | left_ptr |
|
Qt.SizeVerCursor | size_ver |
|
Qt.UpArrowCursor | up_arrow |
|
Qt.SizeHorCursor | size_hor |
|
Qt.CrossCursor | cross |
|
Qt.SizeBDiagCursor | size_bdiag |
|
Qt.IBeamCursor | ibeam |
|
Qt.SizeFDiagCursor | size_fdiag |
|
Qt.WaitCursor | wait |
|
Qt.SizeAllCursor | size_all |
|
Qt.BusyCursor | left_ptr_watch |
|
Qt.SplitVCursor | split_v |
|
Qt.ForbiddenCursor | forbidden |
|
Qt.SplitHCursor | split_h |
|
Qt.PointingHandCursor | pointing_hand |
|
Qt.OpenHandCursor | openhand |
|
Qt.WhatsThisCursor | whats_this |
|
Qt.ClosedHandCursor | closedhand |
| Qt.DragMoveCursor | dnd-move or move | Qt.DragCopyCursor | dnd-copy or copy | ||
| Qt.DragLinkCursor | dnd-link or link |
采用默认箭头形状构造光标。
构造光标采用指定 shape .
见 Qt.CursorShape for a list of shapes.
另请参阅 setShape ().
构造自定义位图光标。
bitmap and mask 构成位图。 hotX and hotY 定义光标的热点。
若 hotX 为负,它被设为 bitmap().width()/2 。若 hotY is negative, it is set 到 bitmap().height()/2 .
光标 bitmap (B) 和 mask (M) bits are combined like this:
使用全局 Qt 颜色 Qt.color0 去绘制 0 像素和 Qt.color1 to draw 1-pixels in the bitmaps.
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.
注意: On Windows CE, the cursor size is fixed. If the pixmap is bigger than the system size, it will be scaled.
另请参阅 QBitmap.QBitmap () 和 QBitmap.setMask ().
构造自定义像素图光标。
pixmap is the image. It is usual to give it a mask (set 使用 QPixmap.setMask ()). hotX and hotY 定义光标的热点。
若 hotX 为负,它被设为 pixmap().width()/2 。若 hotY is negative, it is set 到 pixmap().height()/2 .
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.
注意: On Windows CE, the cursor size is fixed. If the pixmap is bigger than the system size, it will be scaled.
另请参阅 QPixmap.QPixmap () 和 QPixmap.setMask ().
构造拷贝为光标 c .
Constructs a Qt cursor from the given Windows cursor .
警告: This function is only available on Windows.
另请参阅 handle ().
Returns the cursor bitmap, or 0 if it is one of the standard cursors.
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.
Returns the cursor pixmap. This is only valid if the cursor is a pixmap cursor.
Returns the position of the cursor (hot spot) in global screen coordinates.
可以调用 QWidget.mapFromGlobal () 到 translate it to widget coordinates.
另请参阅 setPos (), QWidget.mapFromGlobal (), and QWidget.mapToGlobal ().
Moves the cursor (hot spot) to the global screen position ( x , y ).
可以调用 QWidget.mapToGlobal () to translate widget coordinates to global screen coordinates.
另请参阅 pos (), QWidget.mapFromGlobal (),和 QWidget.mapToGlobal ().
这是重载函数。
Moves the cursor (hot spot) to the global screen position at point p .
将光标设为标识形状通过 shape .
见 Qt.CursorShape for the list of cursor shapes.
另请参阅 shape ().
Returns the cursor shape identifier. The return value is one of the Qt.CursorShape enum values (cast to an int).
另请参阅 setShape ().