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 *) |
QwtPanner::QwtPanner | ( | QWidget * | parent | ) |
Creates an panner that is enabled for the left mouse button.
parent | Parent widget to be panned |
Definition at line 121 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 220 of file qwt_panner.cpp.
Referenced by QwtPanner(), and widgetMousePressEvent().
bool QwtPanner::isEnabled | ( | ) | const |
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 |
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 |
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 188 of file qwt_panner.cpp.
const QCursor QwtPanner::cursor | ( | ) | const |
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 |
bool QwtPanner::isOrientationEnabled | ( | Qt::Orientation | o | ) | const |
Return true if a orientatio is enabled
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.
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
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 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.
me | Mouse event |
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.
me | Mouse event |
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.
ke | Key event |
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.
ke | Key event |
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.
pe | Paint event |
Definition at line 300 of file qwt_panner.cpp.