# QwtPanner Class Reference

Inheritance diagram for QwtPanner:

[legend]
List of all members.

## Detailed Description

QwtPanner provides panning of a widget.

QwtPanner grabs the contents of a widget, that can be dragged in all directions. The offset between the start and the end position is emitted by the panned signal.

QwtPanner grabs the content of the widget into a pixmap and moves the pixmap around, without initiating any repaint events for the widget. Areas, that are not part of content are not painted while panning in in process. This makes panning fast enough for widgets, where repaints are too slow for mouse movements.

For widgets, where repaints are very fast it might be better to implement panning manually by mapping mouse events into paint events.

Definition at line 35 of file qwt_panner.h.

## Signals

void | panned (int dx, int dy)
void | moved (int dx, int dy)

## Public Member Functions

| QwtPanner (QWidget *parent)
virtual | ~QwtPanner ()
void | setEnabled (bool)
bool | isEnabled () const
void | setMouseButton (int button, int buttonState=Qt::NoButton)
void | getMouseButton (int &button, int &buttonState) const
void | setAbortKey (int key, int state=Qt::NoButton)
void | getAbortKey (int &key, int &state) const
void | setCursor (const QCursor &)
const QCursor | cursor () const
void | setOrientations (Qt::Orientations)
Qt::Orientations | orientations () const
bool | isOrientationEnabled (Qt::Orientation) const
virtual bool | eventFilter (QObject *, QEvent *)

## Protected Member Functions

virtual void | widgetMousePressEvent (QMouseEvent *)
virtual void | widgetMouseReleaseEvent (QMouseEvent *)
virtual void | widgetMouseMoveEvent (QMouseEvent *)
virtual void | widgetKeyPressEvent (QKeyEvent *)
virtual void | widgetKeyReleaseEvent (QKeyEvent *)
virtual void | paintEvent (QPaintEvent *)

## Constructor & Destructor Documentation

QwtPanner::QwtPanner | ( | QWidget * | parent | ) |

Creates an panner that is enabled for the left mouse button.

Parameters:

  | parent | Parent widget to be panned

Definition at line 121 of file qwt_panner.cpp.

References setEnabled().

QwtPanner::~QwtPanner | ( |  | ) | `[virtual]`

Destructor.

Definition at line 140 of file qwt_panner.cpp.

## Member Function Documentation

void QwtPanner::setEnabled | ( | bool | on | ) |

En/disable the panner.

When enabled is true an event filter is installed for the observed widget, otherwise the event filter is removed.

Parameters:

  | on | true or false

See also:
  isEnabled(), eventFilter()

Definition at line 220 of file qwt_panner.cpp.

Referenced by QwtPanner(), and widgetMousePressEvent().

bool QwtPanner::isEnabled | ( |  | ) | const

Returns:
  true when enabled, false otherwise

See also:
  setEnabled, eventFilter()

Definition at line 287 of file qwt_panner.cpp.

void QwtPanner::setMouseButton | ( | int | button,
|  | int | buttonState = `Qt::NoButton` |
| ) |  |  |

Change the mouse button The defaults are Qt::LeftButton and Qt::NoButton

Definition at line 149 of file qwt_panner.cpp.

void QwtPanner::getMouseButton | ( | int & | button,
|  | int & | buttonState |
| ) |  |  | const

Get the mouse button.

Definition at line 156 of file qwt_panner.cpp.

void QwtPanner::setAbortKey | ( | int | key,
|  | int | state = `Qt::NoButton` |
| ) |  |  |

Change the abort key The defaults are Qt::Key_Escape and Qt::NoButton

Definition at line 166 of file qwt_panner.cpp.

void QwtPanner::getAbortKey | ( | int & | key,
|  | int & | state |
| ) |  |  | const

Get the abort key.

Definition at line 173 of file qwt_panner.cpp.

void QwtPanner::setCursor | ( | const QCursor & | cursor | ) |

Change the cursor, that is active while panning The default is the cursor of the parent widget.

Parameters:

  | cursor | New cursor

See also:
  setCursor()

Definition at line 188 of file qwt_panner.cpp.

const QCursor QwtPanner::cursor | ( |  | ) | const

Returns:
  Cursor that is active while panning

See also:
  setCursor()

Definition at line 199 of file qwt_panner.cpp.

void QwtPanner::setOrientations | ( | Qt::Orientations | o | ) |

Set the orientations, where panning is enabled The default value is in both directions: Qt::Horizontal | Qt::Vertical

/param o Orientation

Definition at line 249 of file qwt_panner.cpp.

Qt::Orientations QwtPanner::orientations | ( |  | ) | const

Return the orientation, where paning is enabled.

Definition at line 255 of file qwt_panner.cpp.

bool QwtPanner::isOrientationEnabled | ( | Qt::Orientation | o | ) | const

Return true if a orientatio is enabled

See also:
  orientations(), setOrientations()

Definition at line 272 of file qwt_panner.cpp.

Referenced by widgetMouseMoveEvent(), and widgetMouseReleaseEvent().

bool QwtPanner::eventFilter | ( | QObject * | o,
|  | QEvent * | e |
| ) |  |  | `[virtual]`

Event filter.

When isEnabled() the mouse events of the observed widget are filtered.

See also:
  widgetMousePressEvent(), widgetMouseReleaseEvent(), widgetMouseMoveEvent()

Definition at line 341 of file qwt_panner.cpp.

References widgetKeyPressEvent(), widgetKeyReleaseEvent(), widgetMouseMoveEvent(), widgetMousePressEvent(), and widgetMouseReleaseEvent().

void QwtPanner::panned | ( | int | dx,
|  | int | dy |
| ) |  |  | `[signal]`

Signal emitted, when panning is done

Parameters:

  | dx | Offset in horizontal direction
  | dy | Offset in vertical direction

Referenced by QwtPlotPanner::QwtPlotPanner(), and widgetMouseReleaseEvent().

void QwtPanner::moved | ( | int | dx,
|  | int | dy |
| ) |  |  | `[signal]`

Signal emitted, while the widget moved, but panning is not finished.

Parameters:

  | dx | Offset in horizontal direction
  | dy | Offset in vertical direction

Referenced by widgetMouseMoveEvent().

void QwtPanner::widgetMousePressEvent | ( | QMouseEvent * | me | ) | `[protected, virtual]`

Handle a mouse press event for the observed widget.

Parameters:

  | me | Mouse event

See also:
  eventFilter(), widgetMouseReleaseEvent(), widgetMouseMoveEvent(),

Definition at line 392 of file qwt_panner.cpp.

References setEnabled().

Referenced by eventFilter().

void QwtPanner::widgetMouseReleaseEvent | ( | QMouseEvent * | me | ) | `[protected, virtual]`

Handle a mouse release event for the observed widget.

Parameters:

  | me | Mouse event

See also:
  eventFilter(), widgetMousePressEvent(), widgetMouseMoveEvent(),

Definition at line 474 of file qwt_panner.cpp.

References isOrientationEnabled(), and panned().

Referenced by eventFilter().

void QwtPanner::widgetMouseMoveEvent | ( | QMouseEvent * | me | ) | `[protected, virtual]`

Handle a mouse move event for the observed widget.

Parameters:

  | me | Mouse event

See also:
  eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent()

Definition at line 446 of file qwt_panner.cpp.

References isOrientationEnabled(), and moved().

Referenced by eventFilter().

void QwtPanner::widgetKeyPressEvent | ( | QKeyEvent * | ke | ) | `[protected, virtual]`

Handle a key press event for the observed widget.

Parameters:

  | ke | Key event

See also:
  eventFilter(), widgetKeyReleaseEvent()

Definition at line 506 of file qwt_panner.cpp.

Referenced by eventFilter().

void QwtPanner::widgetKeyReleaseEvent | ( | QKeyEvent * |  | ) | `[protected, virtual]`

Handle a key release event for the observed widget.

Parameters:

  | ke | Key event

See also:
  eventFilter(), widgetKeyReleaseEvent()

Definition at line 535 of file qwt_panner.cpp.

Referenced by eventFilter().

void QwtPanner::paintEvent | ( | QPaintEvent * | pe | ) | `[protected, virtual]`

Paint event.

Repaint the grabbed pixmap on its current position and fill the empty spaces by the background of the parent widget.

Parameters:

  | pe | Paint event

Definition at line 300 of file qwt_panner.cpp.