MIRA
Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ScrollView Class Referenceabstract

ScrollView extends the QAbstractScrollArea by features like automatic scaling of scrollbars, signals when the visible are was moved and so on. More...

#include <widgets/ScrollView.h>

Inheritance diagram for ScrollView:
Inheritance graph
[legend]

Signals

void contentsMoving (int x, int y)
 Signal emitted when the position of the content area changed. More...
 

Public Member Functions

 ScrollView (QWidget *parent)
 
int contentsX () const
 The x coordinate of the content area. More...
 
int contentsY () const
 The y coordinate of the content area. More...
 
int contentsHeight () const
 The height of the content area. More...
 
int contentsWidth () const
 The width of the content area. More...
 
void setContentsPos (int x, int y)
 Set the position of the content area. More...
 
void resizeContents (int width, int height)
 Resize the content area. More...
 
void ensureVisible (int x, int y, int marginX=50, int marginY=50)
 Ensures that the position given by x and y with the specified margins is within the content area by scrolling to the respective position. More...
 
QPoint viewportToContents (const QPoint &pos) const
 Converts viewport coordinates to content area coordinates. More...
 
QPoint contentsToViewport (const QPoint &pos) const
 Converts content area coordinates to viewport coordinates. More...
 

Protected Member Functions

void updateScrollBars ()
 
virtual void scrollContentsBy (int dX, int dY)
 
virtual void resizeEvent (QResizeEvent *resizeEvent)
 
virtual void paintEvent (QPaintEvent *paintEvent)
 
virtual void wheelEvent (QWheelEvent *wheelEvent)
 
virtual void drawContents (QPainter *painter, const QRect &rect)=0
 Overload this method in derived classes to draw the content of the content area. More...
 
virtual void updateContents (const QRect &rect)
 Call this method to schedule an update of the content area for the given rect. More...
 
virtual void updateContents ()
 Call this method to schedule an update of the content area. More...
 

Protected Attributes

QRect mContentsRect
 

Detailed Description

ScrollView extends the QAbstractScrollArea by features like automatic scaling of scrollbars, signals when the visible are was moved and so on.

It therefore defines a content area (rect) within a scroll viewport and provides several functions to modify this area. For example it allows synchronization of multiple scroll views showing the same data (in a different way) by connecting the contentsMoving signal of one view to a slot that calls setContentsPos with the respective coordinates in another view.

Constructor & Destructor Documentation

◆ ScrollView()

ScrollView ( QWidget *  parent)

Member Function Documentation

◆ contentsX()

int contentsX ( ) const
inline

The x coordinate of the content area.

◆ contentsY()

int contentsY ( ) const
inline

The y coordinate of the content area.

◆ contentsHeight()

int contentsHeight ( ) const
inline

The height of the content area.

◆ contentsWidth()

int contentsWidth ( ) const
inline

The width of the content area.

◆ setContentsPos()

void setContentsPos ( int  x,
int  y 
)

Set the position of the content area.

◆ resizeContents()

void resizeContents ( int  width,
int  height 
)

Resize the content area.

◆ ensureVisible()

void ensureVisible ( int  x,
int  y,
int  marginX = 50,
int  marginY = 50 
)

Ensures that the position given by x and y with the specified margins is within the content area by scrolling to the respective position.

It is not guaranteed that the margins will be strictly adhered. E.g. if x < marginX or y + marginY > viewport.heigth().

◆ viewportToContents()

QPoint viewportToContents ( const QPoint &  pos) const

Converts viewport coordinates to content area coordinates.

◆ contentsToViewport()

QPoint contentsToViewport ( const QPoint &  pos) const

Converts content area coordinates to viewport coordinates.

◆ contentsMoving

void contentsMoving ( int  x,
int  y 
)
signal

Signal emitted when the position of the content area changed.

◆ updateScrollBars()

void updateScrollBars ( )
protected

◆ scrollContentsBy()

virtual void scrollContentsBy ( int  dX,
int  dY 
)
protectedvirtual

◆ resizeEvent()

virtual void resizeEvent ( QResizeEvent *  resizeEvent)
protectedvirtual

◆ paintEvent()

virtual void paintEvent ( QPaintEvent *  paintEvent)
protectedvirtual

◆ wheelEvent()

virtual void wheelEvent ( QWheelEvent *  wheelEvent)
protectedvirtual

◆ drawContents()

virtual void drawContents ( QPainter *  painter,
const QRect &  rect 
)
protectedpure virtual

Overload this method in derived classes to draw the content of the content area.

◆ updateContents() [1/2]

virtual void updateContents ( const QRect &  rect)
protectedvirtual

Call this method to schedule an update of the content area for the given rect.

Can be overwritten in derived class to do additional update work.

◆ updateContents() [2/2]

virtual void updateContents ( )
protectedvirtual

Call this method to schedule an update of the content area.

Can be overwritten in derived class to do additional update work.

Member Data Documentation

◆ mContentsRect

QRect mContentsRect
protected

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