Struct rute::auto::cursor::Cursor

source ·
pub struct Cursor<'a> { /* private fields */ }
Expand description

Notice these docs are heavy WIP and not very relevent yet

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 QWidget::setCursor(). To associate a cursor with all widgets (normally for a short period of time), use QGuiApplication::setOverrideCursor().

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.

A Note for X11 Users

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 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.

  • Shape

  • Qt::CursorShape Value

  • Cursor Name

  • Shape

  • Qt::CursorShape Value

  • Cursor Name

  • cursor-arrow.png

  • Qt::ArrowCursor

  • left_ptr

  • cursor-sizev.png

  • Qt::SizeVerCursor

  • size_ver

  • cursor-uparrow.png

  • Qt::UpArrowCursor

  • up_arrow

  • cursor-sizeh.png

  • Qt::SizeHorCursor

  • size_hor

  • cursor-cross.png

  • Qt::CrossCursor

  • cross

  • cursor-sizeb.png

  • Qt::SizeBDiagCursor

  • size_bdiag

  • cursor-ibeam.png

  • Qt::IBeamCursor

  • ibeam

  • cursor-sizef.png

  • Qt::SizeFDiagCursor

  • size_fdiag

  • cursor-wait.png

  • Qt::WaitCursor

  • wait

  • cursor-sizeall.png

  • Qt::SizeAllCursor

  • size_all

  • cursor-busy.png

  • Qt::BusyCursor

  • left_ptr_watch

  • cursor-vsplit.png

  • Qt::SplitVCursor

  • split_v

  • cursor-forbidden.png

  • Qt::ForbiddenCursor

  • forbidden

  • cursor-hsplit.png

  • Qt::SplitHCursor

  • split_h

  • cursor-hand.png

  • Qt::PointingHandCursor

  • pointing_hand

  • cursor-openhand.png

  • Qt::OpenHandCursor

  • openhand

  • cursor-whatsthis.png

  • Qt::WhatsThisCursor

  • whats_this

  • cursor-closedhand.png

  • Qt::ClosedHandCursor

  • closedhand

  • Qt::DragMoveCursor

  • dnd-move or move

  • Qt::DragCopyCursor

  • dnd-copy or copy

  • Qt::DragLinkCursor

  • dnd-link or link

See also: Widget {fowler}{GUI Design Handbook: Cursors}

Licence

The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.

Implementations

Swaps this cursor with the other cursor.

Returns the cursor shape identifier. The return value is one of the Qt::CursorShape enum values (cast to an int).

See also: [set_shape()]

Sets the cursor to the shape identified by shape.

See Qt::CursorShape for the list of cursor shapes.

See also: [shape()]

Returns the cursor bitmap, or 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 cursor hot spot, or (0, 0) if it is one of the standard cursors.

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

You can call QWidget::mapFromGlobal() to translate it to widget coordinates.

See also: [set_pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapFromGlobal() to translate it to widget coordinates.

Note: The position is queried from the windowing system. If mouse events are generated via other means (e.g., via QWindowSystemInterface in a unit test), those fake mouse moves will not be reflected in the returned value.

Note: On platforms where there is no windowing system or cursors are not available, the returned position is based on the mouse move events generated via QWindowSystemInterface.

See also: [set_pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

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

You can call QWidget::mapFromGlobal() to translate it to widget coordinates.

See also: [set_pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapFromGlobal() to translate it to widget coordinates.

Note: The position is queried from the windowing system. If mouse events are generated via other means (e.g., via QWindowSystemInterface in a unit test), those fake mouse moves will not be reflected in the returned value.

Note: On platforms where there is no windowing system or cursors are not available, the returned position is based on the mouse move events generated via QWindowSystemInterface.

See also: [set_pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

Note: Calling this function results in changing the cursor position through the windowing system. The windowing system will typically respond by sending mouse events to the application’s window. This means that the usage of this function should be avoided in unit tests and everywhere where fake mouse events are being injected via QWindowSystemInterface because the windowing system’s mouse state (with regards to buttons for example) may not match the state in the application-generated events.

Note: On platforms where there is no windowing system or cursors are not available, this function may do nothing.

See also: [pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

See also: [pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

Overloads Moves the cursor (hot spot) to the global screen position at point p.

Overloads Moves the cursor (hot spot) to the global screen position of the screen at point p.

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

Note: Calling this function results in changing the cursor position through the windowing system. The windowing system will typically respond by sending mouse events to the application’s window. This means that the usage of this function should be avoided in unit tests and everywhere where fake mouse events are being injected via QWindowSystemInterface because the windowing system’s mouse state (with regards to buttons for example) may not match the state in the application-generated events.

Note: On platforms where there is no windowing system or cursors are not available, this function may do nothing.

See also: [pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

See also: [pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

Overloads Moves the cursor (hot spot) to the global screen position at point p.

Overloads Moves the cursor (hot spot) to the global screen position of the screen at point p.

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

Note: Calling this function results in changing the cursor position through the windowing system. The windowing system will typically respond by sending mouse events to the application’s window. This means that the usage of this function should be avoided in unit tests and everywhere where fake mouse events are being injected via QWindowSystemInterface because the windowing system’s mouse state (with regards to buttons for example) may not match the state in the application-generated events.

Note: On platforms where there is no windowing system or cursors are not available, this function may do nothing.

See also: [pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

See also: [pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

Overloads Moves the cursor (hot spot) to the global screen position at point p.

Overloads Moves the cursor (hot spot) to the global screen position of the screen at point p.

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

Note: Calling this function results in changing the cursor position through the windowing system. The windowing system will typically respond by sending mouse events to the application’s window. This means that the usage of this function should be avoided in unit tests and everywhere where fake mouse events are being injected via QWindowSystemInterface because the windowing system’s mouse state (with regards to buttons for example) may not match the state in the application-generated events.

Note: On platforms where there is no windowing system or cursors are not available, this function may do nothing.

See also: [pos()] Widget::map_from_global Widget::map_to_global

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

You can call QWidget::mapToGlobal() to translate widget coordinates to global screen coordinates.

See also: [pos()] Widget::map_from_global Widget::map_to_global GuiApplication::primary_screen

Overloads Moves the cursor (hot spot) to the global screen position at point p.

Overloads Moves the cursor (hot spot) to the global screen position of the screen at point p.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.