KCursor Class Reference
from PyKDE4.kdeui import *
Inherits: QCursor
Detailed Description
The KCursor class extends QCursor with the ability to create an arbitrary named cursor from the cursor theme, and provides a set of static convenience methods for auto-hiding cursors on widgets.
Methods | |
__init__ (self, QString name, Qt::CursorShape fallback=Qt.ArrowCursor) | |
__init__ (self, QCursor cursor) | |
Static Methods | |
autoHideEventFilter (QObject a0, QEvent a1) | |
int | hideCursorDelay () |
setAutoHideCursor (QWidget w, bool enable, bool customEventFilter=0) | |
setHideCursorDelay (int ms) |
Method Documentation
__init__ | ( | self, | ||
QString | name, | |||
Qt::CursorShape | fallback=Qt.ArrowCursor | |||
) |
Attempts to load the requested name cursor from the current theme.
This allows one to access cursors that may be in a theme but not in the Qt.CursorShape enum.
If the specified cursor doesn't exist in the theme, or if KDE was built without Xcursor support, the cursor will be loaded from the X11 cursor font instead. If the cursor doesn't exist in the cursor font, it falls back to the Qt.CursorShape provided as the second parameter.
On platforms other than X11, the fallback shape is always used.
- Parameters:
-
name the name of the cursor to try and load fallback the cursor to load if name cursor can not be loaded
__init__ | ( | self, | ||
QCursor | cursor | |||
) |
Creates a copy of cursor.
Static Method Documentation
KCursor has to install an eventFilter over the widget you want to auto-hide. If you have an own eventFilter() on that widget and stop some events by returning true, you might break auto-hiding, because KCursor doesn't get those events.
In this case, you need to call setAutoHideCursor( widget, true, true ); to tell KCursor not to install an eventFilter. Then you call this method from the beginning of your eventFilter, for example:
edit = new KEdit( this, "some edit widget" ); edit->installEventFilter( this ); KCursor.setAutoHideCursor( edit, true, true ); [...] bool YourClass.eventFilter( QObject *o, QEvent *e ) { if ( o == edit ) // only that widget where you enabled auto-hide! KCursor.autoHideEventFilter( o, e ); // now you can do your own event-processing [...] }
Note that you must not call KCursor.autoHideEventFilter() when you didn't enable or after disabling auto-hiding.
int hideCursorDelay | ( | ) |
- Returns:
- the current auto-hide delay time.
Default is 5000, i.e. 5 seconds.
setAutoHideCursor | ( | QWidget | w, | |
bool | enable, | |||
bool | customEventFilter=0 | |||
) |
Sets auto-hiding the cursor for widget w. Enabling it will result in the cursor being hidden when
The cursor will be shown again when the focus is lost or a mouse-event happens.
Side effect: when enabling auto-hide, mouseTracking is enabled for the specified widget, because it's needed to get mouse-move-events. So don't disable mouseTracking for a widget while using auto-hide for it.
When disabling auto-hide, mouseTracking will be disabled, so if you need mouseTracking after disabling auto-hide, you have to reenable mouseTracking.
If you want to use auto-hiding for widgets that don't take focus, e.g. a QCanvasView, then you have to pass all key-events that should trigger auto-hiding to autoHideEventFilter().
setHideCursorDelay | ( | int | ms | |
) |
Sets the delay time in milliseconds for auto-hiding. When no keyboard events arrive for that time-frame, the cursor will be hidden.
Default is 5000, i.e. 5 seconds.