KanoopGuiQt 1.3.0
Qt GUI utility library
Loading...
Searching...
No Matches
GraphicsView Class Reference

QGraphicsView subclass with built-in mouse pan and wheel zoom support. More...

#include <graphicsview.h>

+ Inheritance diagram for GraphicsView:
+ Collaboration diagram for GraphicsView:

Signals

void scaleChanged (double scale)
 Emitted when the view scale changes.
 
void resized (const Size &newSize, const Size &oldSize)
 Emitted when the viewport is resized.
 

Public Member Functions

 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.
 

Protected Member Functions

virtual void resizeEvent (QResizeEvent *event) override
 Emit resized() with old and new viewport sizes.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GraphicsView()

GraphicsView::GraphicsView ( QWidget *  parent = nullptr)
explicit

Construct with an optional parent widget.

Parameters
parentOptional QWidget parent

Member Function Documentation

◆ 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
newSizeNew viewport size
oldSizePrevious viewport size

◆ scaleChanged

void GraphicsView::scaleChanged ( double  scale)
signal

Emitted when the view scale changes.

Parameters
scaleNew scale factor

◆ setPanEnabled()

void GraphicsView::setPanEnabled ( bool  value)
inline

Enable or disable mouse-drag panning.

Parameters
valuetrue to enable pan

Definition at line 41 of file graphicsview.h.

◆ setScaleFactor()

void GraphicsView::setScaleFactor ( double  factor)

Set the view scale to an absolute factor.

Parameters
factorScale factor (1.0 = no zoom)

◆ setZoomEnabled()

void GraphicsView::setZoomEnabled ( bool  value)
inline

Enable or disable mouse-wheel zooming.

Parameters
valuetrue to enable zoom

Definition at line 53 of file graphicsview.h.


The documentation for this class was generated from the following file: