Home · All Classes · Main Classes · Deprecated
Public Slots | Signals | Public Member Functions | Properties

MPannableViewport Class Reference

MPannableViewport is a viewport widget which can be used to make any widget pannable. More...

Inherits MPannableWidget.

List of all members.

Public Slots

virtual void updatePosition (const QPointF &position)

Signals

void viewportSizeChanged (const QSizeF &viewportSize)

Public Member Functions

 MPannableViewport (QGraphicsItem *parent=0)
virtual ~MPannableViewport ()
void setAutoRange (bool enable)
bool autoRange () const
void setClipping (bool enabled)
bool hasClipping () const
void setWidget (QGraphicsWidget *widget)
QGraphicsWidgetwidget () const
void setPositionIndicator (MPositionIndicator *positionIndicator)
MPositionIndicatorpositionIndicator () const

Properties

bool autoRange
QRectF range
QGraphicsWidget widget
bool clipping

Detailed Description

MPannableViewport is a viewport widget which can be used to make any widget pannable.

MPannableViewport contains a widget (set with setWidget()) and displays it inside the viewport. The area is monitored for panning gestures and when one is detected, the widget is scrolled in the viewport. Other mouse events are forwarded to the panned widget.

sizePosChanged() signal is emitted when the size of the viewport, the the panned range or the position of the panning changes. It can be used to track the currently visible area of the widget.

Viewport has an autoRange feature which sets the panning range based on the preferred size of the panned widget. This can be turned off after which the method setRange() can be used to set the panning range.

The viewport creates a position indicator widget on top of it which shows the panning position. The position indicator is accesible by the positionIndicator() accessor and can be disabled by using setEnabled(bool) method.

By default, the viewport is created with minimum size of 0x0 pixels and preferred size of 1x1 pixels. In order to show the contents of the viewport it needs to be put into layout which will extend it or minimum size of it needs to be increased. This can be achived by styling the widget or as in line 2 of the example.

Example:

     MPannableViewport* viewport = new MPannableViewport(parent);
     viewport->setMinimumSize(100,100);
     MImage* image = new MImage("myimage.png");
     viewport->setWidget(image);
See also:
MPannableWidget MPannableWidgetStyle

Constructor & Destructor Documentation

MPannableViewport::MPannableViewport ( QGraphicsItem parent = 0  )  [explicit]

Constructs a pannable viewport with a parent.

MPannableViewport::~MPannableViewport (  )  [virtual]

Destroys the pannable widget.


Member Function Documentation

bool MPannableViewport::autoRange (  )  const

Returns the state of the autoRange feature.

bool MPannableViewport::hasClipping (  )  const

Returns the clipping state.

MPositionIndicator * MPannableViewport::positionIndicator (  )  const

Returns the position indicator which is currently used.

void MPannableViewport::setAutoRange ( bool  enable  ) 

Sets the state of the autoRange feature.

When AutoRange is set on, the panning range is automatically determined based on the size() of the panned widget.

void MPannableViewport::setClipping ( bool  enabled  ) 

Sets the clipping state of the panned widget.

Normally this needs to be true. It can be set to false if the pannable viewport occupies the whole screen in which case the clipping of the panned widget to viewport is redundant.

void MPannableViewport::setPositionIndicator ( MPositionIndicator positionIndicator  ) 

Sets the positionIndicator which will be used instead of the current one.

Ownership of the indicator is transferred to pannable viewport.

void MPannableViewport::setWidget ( QGraphicsWidget widget  ) 

Sets the widget which will be displayed and panned in the viewport.

Ownership of the widget is transferred to pannable viewport.

void MPannableViewport::updatePosition ( const QPointF position  )  [virtual, slot]

Receives the position updates from the physics and moves the panned widget based on them.

This slot should only be used by physics engine.

Reimplemented from MPannableWidget.

void MPannableViewport::viewportSizeChanged ( const QSizeF viewportSize  )  [signal]

When viewport size changes this signal is emitted.

QGraphicsWidget* MPannableViewport::widget (  )  const

Returns the widget which is currently panned.


Property Documentation

bool MPannableViewport::autoRange [read, write]

Enable status of autoRange feature.

bool MPannableViewport::clipping [read, write]

Clipping status of the panned widget.

QRectF MPannableViewport::range [read, write]

Current panning range.

Reimplemented from MPannableWidget.

QGraphicsWidget * MPannableViewport::widget [read, write]

Current panned widget.


Copyright © 2010 Nokia Corporation
MeeGo Touch