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 |
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 *) |
QwtPanner::QwtPanner | ( | QWidget * | parent | ) |
Creates an panner that is enabled for the left mouse button.
parent | Parent widget to be panned |
Definition at line 108 of file qwt_panner.cpp.
References setEnabled().
QwtPanner::~QwtPanner | ( | ) | [virtual] |
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.
on | true or false |
Definition at line 207 of file qwt_panner.cpp.
Referenced by QwtPanner(), and widgetMousePressEvent().
bool QwtPanner::isEnabled | ( | ) | const |
Definition at line 233 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 136 of file qwt_panner.cpp.
void QwtPanner::getMouseButton | ( | int & | button, | |
int & | buttonState | |||
) | const |
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 153 of file qwt_panner.cpp.
void QwtPanner::getAbortKey | ( | int & | key, | |
int & | state | |||
) | const |
void QwtPanner::setCursor | ( | const QCursor & | cursor | ) |
Change the cursor, that is active while panning The default is the cursor of the parent widget.
cursor | New cursor |
Definition at line 175 of file qwt_panner.cpp.
const QCursor QwtPanner::cursor | ( | ) | const |
Definition at line 186 of file qwt_panner.cpp.
bool QwtPanner::eventFilter | ( | QObject * | o, | |
QEvent * | e | |||
) | [virtual] |
Event filter.
When isEnabled() the mouse events of the observed widget are filtered.
Definition at line 287 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
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.
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.
me | Mouse event |
Definition at line 332 of file qwt_panner.cpp.
References setEnabled().
Referenced by eventFilter().
void QwtPanner::widgetMouseReleaseEvent | ( | QMouseEvent * | me | ) | [protected, virtual] |
Handle a mouse move event for the observed widget.
Definition at line 404 of file qwt_panner.cpp.
References panned().
Referenced by eventFilter().
void QwtPanner::widgetMouseMoveEvent | ( | QMouseEvent * | me | ) | [protected, virtual] |
Handle a mouse release event for the observed widget.
me | Mouse event |
Definition at line 387 of file qwt_panner.cpp.
References moved().
Referenced by eventFilter().
void QwtPanner::widgetKeyPressEvent | ( | QKeyEvent * | ke | ) | [protected, virtual] |
Handle a key press event for the observed widget.
ke | Key event |
Definition at line 430 of file qwt_panner.cpp.
Referenced by eventFilter().
void QwtPanner::widgetKeyReleaseEvent | ( | QKeyEvent * | ) | [protected, virtual] |
Handle a key release event for the observed widget.
ke | Key event |
Definition at line 459 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.
pe | Paint event |
Definition at line 246 of file qwt_panner.cpp.