• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QKeySequence

    下一话题

    QFontInfo

    QCursor

    概要

    函数

    静态函数

    详细描述

    PySide.QtGui.QCursor class provides a mouse cursor with an arbitrary shape.

    此类主要用于创建关联特定 Widget 的鼠标光标,及获取和设置鼠标光标的位置。

    Qt 有许多标准光标形状,但也可以制作自定义光标形状基于 PySide.QtGui.QBitmap 、遮罩及热点。

    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 PySide.QtGui.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 PySide.QtGui.QCursor constructor which takes a bitmap and a mask or the constructor which takes a pixmap as arguments.

    要设置 (或获取) 鼠标光标的位置,使用静态方法 QCursor.pos() and QCursor.setPos() .

    注意

    It is possible to create a PySide.QtGui.QCursor before PySide.QtGui.QApplication , but it is not useful except as a place-holder for a real PySide.QtGui.QCursor created after PySide.QtGui.QApplication . Attempting to use a PySide.QtGui.QCursor that was created before PySide.QtGui.QApplication 将导致崩溃。

    X11 用户注意事项

    On X11, Qt supports the Xcursor library, which allows for full color icon themes. The table below shows the cursor name used for each Qt.CursorShape 值。若使用以下展示的名称找不到光标,则使用标准 X11 光标代替。注意:X11 没有提供适当光标为所有可能的 Qt.CursorShape 值。某些游标可能获取自 Xcursor 主题,而其它的使用内部位图光标。

    另请参阅

    PySide.QtGui.QWidget GUI Design Handbook: Cursors

    class PySide.QtGui. QCursor
    class PySide.QtGui. QCursor ( shape )
    class PySide.QtGui. QCursor ( bitmap , mask [ , hotX=-1 [ , hotY=-1 ] ] )
    class PySide.QtGui. QCursor ( cursor )
    class PySide.QtGui. QCursor ( pixmap [ , hotX=-1 [ , hotY=-1 ] ] )
    参数:

    采用默认箭头形状构造光标。

    构造自定义位图光标。

    bitmap and mask 构成位图。 hotX and hotY 定义光标的热点。

    hotX 为负数,它被设为 bitmap().width()/2 。若 hotY 为负数,它被设为 bitmap().height()/2 .

    光标 bitmap (B) 和 mask (M) 位的组合像这样:

    • B=1 和 M=1 给出黑色。
    • B=0 和 M=1 给出白色。
    • B=0 和 M=0 给出透明。
    • B=1 和 M=0 在 Windows 给出 XOR (异或) 结果,在所有其他平台给出未定义结果。

    使用全局 Qt 颜色 Qt.color0 去绘制 0 像素和 Qt.color1 去绘制 1 像素在位图中。

    有效光标大小从属显示硬件 (或底层窗口系统)。推荐使用 32 x 32 的光标,因为所有平台支持此大小。某些平台还支持 16 x 16、48 x 48 及 64 x 64 光标。

    注意

    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()

    构造拷贝为光标 c .

    构造自定义像素图光标。

    pixmap 是图像。它通常给出遮罩 (设置使用 QPixmap.setMask() ). hotX and hotY 定义光标的热点。

    hotX 为负数,它被设为 pixmap().width()/2 。若 hotY 为负数,它被设为 pixmap().height()/2 .

    有效光标大小从属显示硬件 (或底层窗口系统)。推荐使用 32 x 32 的光标,因为所有平台支持此大小。某些平台还支持 16 x 16、48 x 48 及 64 x 64 光标。

    注意

    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()

    PySide.QtGui.QCursor. bitmap ( )
    返回类型: PySide.QtGui.QBitmap

    Returns the cursor bitmap, or 0 if it is one of the standard cursors.

    PySide.QtGui.QCursor. handle ( )
    返回类型: PySide.QtCore.Qt::HANDLE

    Returns a platform-specific cursor handle. The HCURSOR_or_HANDLE type is HCURSOR 在 Windows 和 Qt.HANDLE on X11 and Mac OS X. On Qt for Embedded Linux it is an integer.

    警告

    Using the value returned by this function is not portable.

    PySide.QtGui.QCursor. hotSpot ( )
    返回类型: PySide.QtCore.QPoint

    返回光标热点,或 (0, 0) 若它是标准光标之一。

    PySide.QtGui.QCursor. mask ( )
    返回类型: PySide.QtGui.QBitmap

    Returns the cursor bitmap mask, or 0 if it is one of the standard cursors.

    PySide.QtGui.QCursor. pixmap ( )
    返回类型: PySide.QtGui.QPixmap

    返回光标像素图。这才有效,若光标是像素图光标。

    static PySide.QtGui.QCursor. pos ( )
    返回类型: PySide.QtCore.QPoint

    Returns the position of the cursor (hot spot) in global screen coordinates.

    可以调用 QWidget.mapFromGlobal() to translate it to widget coordinates.

    static PySide.QtGui.QCursor. setPos ( x , y )
    参数:
    • x PySide.QtCore.int
    • y PySide.QtCore.int

    Moves the cursor (hot spot) to the global screen position ( x , y ).

    可以调用 QWidget.mapToGlobal() to translate widget coordinates to global screen coordinates.

    static PySide.QtGui.QCursor. setPos ( p )
    参数: p PySide.QtCore.QPoint

    这是重载函数。

    把光标 (热点) 移动全局屏幕位置,在点 p .

    PySide.QtGui.QCursor. setShape ( newShape )
    参数: newShape PySide.QtCore.Qt.CursorShape
    PySide.QtGui.QCursor. shape ( )
    返回类型: PySide.QtCore.Qt.CursorShape

    返回光标形状标识符。返回值是某一 Qt.CursorShape 枚举值 (铸造成 int)。