• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Member Functions | Static Public Member Functions | List of all members
KCursor Class Reference

#include <kcursor.h>

Inheritance diagram for KCursor:
Inheritance graph
[legend]

Public Member Functions

 KCursor (const QString &name, Qt::CursorShape fallback=Qt::ArrowCursor)
 
 KCursor (const QCursor &cursor)
 
KCursor & operator= (const KCursor &cursor)
 
- Public Member Functions inherited from QCursor
 QCursor ()
 
 QCursor (Qt::HANDLE handle)
 
 QCursor (Qt::CursorShape shape)
 
 QCursor (const QPixmap &pixmap, int hotX, int hotY)
 
 QCursor (HCURSOR cursor)
 
 QCursor (const QCursor &c)
 
 QCursor (const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
 
 ~QCursor ()
 
const QBitmap * bitmap () const
 
HCURSOR_or_HANDLE handle () const
 
QPoint hotSpot () const
 
const QBitmap * mask () const
 
 operator QVariant () const
 
QCursor & operator= (const QCursor &c)
 
QPixmap pixmap () const
 
void setShape (Qt::CursorShape shape)
 
Qt::CursorShape shape () const
 

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)
 
- Static Public Member Functions inherited from QCursor
QPoint pos ()
 
void setPos (const QPoint &p)
 
void setPos (int x, int y)
 

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.

Author
Kurt Granroth granr.nosp@m.oth@.nosp@m.kde.o.nosp@m.rg

Definition at line 36 of file kcursor.h.

Constructor & Destructor Documentation

KCursor::KCursor ( const QString &  name,
Qt::CursorShape  fallback = Qt::ArrowCursor 
)
explicit

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
namethe name of the cursor to try and load
fallbackthe cursor to load if name cursor can not be loaded

Definition at line 170 of file kcursor.cpp.

KCursor::KCursor ( const QCursor &  cursor)

Creates a copy of cursor.

Definition at line 191 of file kcursor.cpp.

Member Function Documentation

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

Definition at line 208 of file kcursor.cpp.

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

Default is 5000, i.e. 5 seconds.

Definition at line 218 of file kcursor.cpp.

KCursor & KCursor::operator= ( const KCursor &  cursor)

Assigns cursor to this cursor, and returns a reference to this cursor.

Definition at line 196 of file kcursor.cpp.

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

Definition at line 202 of file kcursor.cpp.

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 213 of file kcursor.cpp.


The documentation for this class was generated from the following files:
  • kcursor.h
  • kcursor.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal