Cursor
Qt Base Class: QCursor
Signature: QCursor(self) -> None
QCursor(self, bitmap: Union[PySide6.QtGui.QBitmap, str], mask: Union[PySide6.QtGui.QBitmap, str], hotX: int = -1, hotY: int = -1) -> None
QCursor(self, cursor: Union[PySide6.QtGui.QCursor, PySide6.QtCore.Qt.CursorShape, PySide6.QtGui.QPixmap]) -> None
QCursor(self, pixmap: Union[PySide6.QtGui.QPixmap, PySide6.QtGui.QImage, str], hotX: int = -1, hotY: int = -1) -> None
QCursor(self, shape: PySide6.QtCore.Qt.CursorShape) -> None
Base classes
Name | Children | Inherits |
---|---|---|
SerializeMixin prettyqt.utils.serializemixin |
||
QCursor PySide6.QtGui QCursor(self) -> None |
⋔ Inheritance diagram
graph TD
1473245640224["gui.Cursor"]
1473299806240["utils.SerializeMixin"]
140713234304496["builtins.object"]
1473300169232["QtGui.QCursor"]
1473291690208["Shiboken.Object"]
1473299806240 --> 1473245640224
140713234304496 --> 1473299806240
1473300169232 --> 1473245640224
1473291690208 --> 1473300169232
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: SerializeMixin
, QCursor
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.
To associate a cursor with a widget, use widget.set_cursor()
.
To associate a cursor with all widgets (normally for a short period of time),
use GuiApplication.set_override_cursor()
.
To set a cursor shape use 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
enum.
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()
and QCursor.setPos()
.
!!! note: It is possible to create a QCursor before QGuiApplication, but it is not useful except as a place-holder for a real QCursor created after QGuiApplication. Attempting to use a QCursor that was created before QGuiApplication will result in a crash.
Source code in prettyqt\gui\cursor.py
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 180 181 182 183 184 185 186 187 188 189 |
|
get_shape() -> constants.CursorShapeStr
set_pos(where: Literal['screen', 'current'] | gui.QScreen | widgets.QWidget | core.QRect | core.QPoint | tuple[int, int] | tuple[int, int, int, int], how: Literal['center', 'top', 'left', 'bottom', 'right', 'top_left', 'top_right', 'bottom_left', 'bottom_right'] = 'center', x_offset: int = 0, y_offset: int = 0, duration: int = 0)
classmethod
Position cursor onto screen position / widget / window / screen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
where |
Literal['screen', 'current'] | QScreen | QWidget | QRect | QPoint | tuple[int, int] | tuple[int, int, int, int]
|
where to position on |
required |
how |
Literal['center', 'top', 'left', 'bottom', 'right', 'top_left', 'top_right', 'bottom_left', 'bottom_right']
|
How to align |
'center'
|
x_offset |
int
|
additional x offset for final position |
0
|
y_offset |
int
|
additional y offset for final position |
0
|
duration |
int
|
movement time |
0
|
Source code in prettyqt\gui\cursor.py
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 180 181 182 183 184 185 186 187 188 189 |
|
set_shape(shape: constants.CursorShapeStr)
Set cursor shape.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape |
CursorShapeStr
|
shape to use |
required |