QGraphicsView subclass with built-in mouse pan and wheel zoom support.
More...
#include <graphicsview.h>
|
| void | scaleChanged (double scale) |
| | Emitted when the view scale changes.
|
| |
| void | resized (const Size &newSize, const Size &oldSize) |
| | Emitted when the viewport is resized.
|
| |
|
| | GraphicsView (QWidget *parent=nullptr) |
| | Construct with an optional parent widget.
|
| |
| bool | panEnabled () const |
| | Return whether mouse-drag panning is enabled.
|
| |
| void | setPanEnabled (bool value) |
| | Enable or disable mouse-drag panning.
|
| |
| bool | isZoomEnabled () const |
| | Return whether mouse-wheel zooming is enabled.
|
| |
| void | setZoomEnabled (bool value) |
| | Enable or disable mouse-wheel zooming.
|
| |
| void | setScaleFactor (double factor) |
| | Set the view scale to an absolute factor.
|
| |
| double | currentScale () const |
| | Return the current horizontal scale of the view transform.
|
| |
|
|
virtual void | resizeEvent (QResizeEvent *event) override |
| | Emit resized() with old and new viewport sizes.
|
| |
QGraphicsView subclass with built-in mouse pan and wheel zoom support.
GraphicsView installs itself as an event filter and handles wheel events for zooming and mouse button press/move/release events for panning. Both features can be enabled or disabled at runtime. scaleChanged() is emitted whenever the view transform changes, and resized() is emitted on resize events.
Definition at line 20 of file graphicsview.h.
◆ GraphicsView()
| GraphicsView::GraphicsView |
( |
QWidget * |
parent = nullptr | ) |
|
|
explicit |
Construct with an optional parent widget.
- Parameters
-
| parent | Optional QWidget parent |
◆ currentScale()
| double GraphicsView::currentScale |
( |
| ) |
const |
Return the current horizontal scale of the view transform.
- Returns
- Current scale factor
◆ isZoomEnabled()
| bool GraphicsView::isZoomEnabled |
( |
| ) |
const |
|
inline |
Return whether mouse-wheel zooming is enabled.
- Returns
- true if zoom is enabled
Definition at line 47 of file graphicsview.h.
◆ panEnabled()
| bool GraphicsView::panEnabled |
( |
| ) |
const |
|
inline |
Return whether mouse-drag panning is enabled.
- Returns
- true if pan is enabled
Definition at line 35 of file graphicsview.h.
◆ resized
| void GraphicsView::resized |
( |
const Size & |
newSize, |
|
|
const Size & |
oldSize |
|
) |
| |
|
signal |
Emitted when the viewport is resized.
- Parameters
-
| newSize | New viewport size |
| oldSize | Previous viewport size |
◆ scaleChanged
| void GraphicsView::scaleChanged |
( |
double |
scale | ) |
|
|
signal |
Emitted when the view scale changes.
- Parameters
-
◆ setPanEnabled()
| void GraphicsView::setPanEnabled |
( |
bool |
value | ) |
|
|
inline |
Enable or disable mouse-drag panning.
- Parameters
-
Definition at line 41 of file graphicsview.h.
◆ setScaleFactor()
| void GraphicsView::setScaleFactor |
( |
double |
factor | ) |
|
Set the view scale to an absolute factor.
- Parameters
-
| factor | Scale factor (1.0 = no zoom) |
◆ setZoomEnabled()
| void GraphicsView::setZoomEnabled |
( |
bool |
value | ) |
|
|
inline |
Enable or disable mouse-wheel zooming.
- Parameters
-
Definition at line 53 of file graphicsview.h.
The documentation for this class was generated from the following file: