Qwt User's Guide: QwtPanner Class Reference

Qwt User's Guide 6.0.1

- Main Page
- Related Pages
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Signals | Public Member Functions | Protected Member Functions

# QwtPanner Class Reference

QwtPanner provides panning of a widget. More...

`#include <qwt_panner.h>`

Inheritance diagram for QwtPanner:
[legend]

List of all members.

## Signals
void | moved (int dx, int dy)
void | panned (int dx, int dy)
## Public Member Functions
const QCursor | cursor () const
virtual bool | eventFilter (QObject *, QEvent *)
void | getAbortKey (int &key, int &state) const
void | getMouseButton (int &button, int &buttonState) const
bool | isEnabled () const
bool | isOrientationEnabled (Qt::Orientation) const
Qt::Orientations | orientations () const
| QwtPanner (QWidget *parent)
void | setAbortKey (int key, int state=Qt::NoButton)
void | setCursor (const QCursor &)
void | setEnabled (bool)
void | setMouseButton (int button, int buttonState=Qt::NoButton)
void | setOrientations (Qt::Orientations)
virtual | ~QwtPanner ()
## Protected Member Functions
virtual QBitmap | contentsMask () const
virtual QPixmap | grab () const
virtual void | paintEvent (QPaintEvent *)
virtual void | widgetKeyPressEvent (QKeyEvent *)
virtual void | widgetKeyReleaseEvent (QKeyEvent *)
virtual void | widgetMouseMoveEvent (QMouseEvent *)
virtual void | widgetMousePressEvent (QMouseEvent *)
virtual void | widgetMouseReleaseEvent (QMouseEvent *)

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

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

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

Destructor.

## Member Function Documentation

QBitmap QwtPanner::contentsMask | ( |  | ) | const`[protected, virtual]`

Calculate a mask for the contents of the panned widget.

Sometimes only parts of the contents of a widget should be panned. F.e. for a widget with a styled background with rounded borders only the area inside of the border should be panned.

Returns:
  An empty bitmap, indicating no mask

Reimplemented in QwtPlotPanner.

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

Returns:
  Cursor that is active while panning

See also:
  setCursor()

bool QwtPanner::eventFilter | ( | QObject * | object,
|  | QEvent * | event
| ) |  | `[virtual]`

Event filter.

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

Parameters:

  object | Object to be filtered
  event | Event

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

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

Get the abort key.

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

Get the mouse button.

QPixmap QwtPanner::grab | ( |  | ) | const`[protected, virtual]`

Grab the widget into a pixmap.

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

Returns:
  true when enabled, false otherwise

See also:
  setEnabled, eventFilter()

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

Return true if a orientatio is enabled

See also:
  orientations(), setOrientations()

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

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

Return the orientation, where paning is enabled.

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

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

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

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

Parameters:

  key | Key ( See Qt::Keycode )
  state | State

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

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

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

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

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

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

Handle a key press event for the observed widget.

Parameters:

  keyEvent | Key event

See also:
  eventFilter(), widgetKeyReleaseEvent()

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

Handle a key release event for the observed widget.

Parameters:

  keyEvent | Key event

See also:
  eventFilter(), widgetKeyReleaseEvent()

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

Handle a mouse move event for the observed widget.

Parameters:

  mouseEvent | Mouse event

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

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

Handle a mouse press event for the observed widget.

Parameters:

  mouseEvent | Mouse event

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

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

Handle a mouse release event for the observed widget.

Parameters:

  mouseEvent | Mouse event

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