KCursor

Search for usage in LXR

#include <KCursor>

Static Public Member Functions

static void autoHideEventFilter (QObject *, QEvent *)
 
static int hideCursorDelay ()
 
static void setAutoHideCursor (QWidget *w, bool enable, bool customEventFilter=false)
 
static void setHideCursorDelay (int ms)
 

Detailed Description

The KCursor class provides a set of static convenience methods for auto-hiding cursors on widgets.

Definition at line 24 of file kcursor.h.

Member Function Documentation

◆ autoHideEventFilter()

void KCursor::autoHideEventFilter ( QObject * o,
QEvent * e )
static

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!
// now you can do your own event-processing
[...]
}
static void setAutoHideCursor(QWidget *w, bool enable, bool customEventFilter=false)
Sets auto-hiding the cursor for widget w.
Definition kcursor.cpp:17
static void autoHideEventFilter(QObject *, QEvent *)
KCursor has to install an eventFilter over the widget you want to auto-hide.
Definition kcursor.cpp:22

Note that you must not call KCursor::autoHideEventFilter() when you didn't enable or after disabling auto-hiding.

Definition at line 22 of file kcursor.cpp.

◆ hideCursorDelay()

int KCursor::hideCursorDelay ( )
static
Returns
the current auto-hide delay time.

Default is 5000, i.e. 5 seconds.

Definition at line 32 of file kcursor.cpp.

◆ setAutoHideCursor()

void KCursor::setAutoHideCursor ( QWidget * w,
bool enable,
bool customEventFilter = false )
static

Sets auto-hiding the cursor for widget w.

Enabling it will result in the cursor being hidden when

  • a key-event happens
  • there are no key-events for a configured time-frame (see setHideCursorDelay())

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 re-enable 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().

Definition at line 17 of file kcursor.cpp.

◆ setHideCursorDelay()

void KCursor::setHideCursorDelay ( int ms)
static

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.

Definition at line 27 of file kcursor.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.