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

MImageWidget Class Reference

MImageWidget is a simple widget to show image. More...

Inherits MWidgetController.

List of all members.

Public Slots

void setImage (const QString &id)
void setImage (const QImage &image)
void setPixmap (const QPixmap &pixmap)

Public Member Functions

 MImageWidget (QGraphicsItem *parent=0)
 MImageWidget (const QString &id, QGraphicsItem *parent=0)
 MImageWidget (const QImage *image, QGraphicsItem *parent=0)
 MImageWidget (const QPixmap *pixmap, QGraphicsItem *parent=0)
 MImageWidget (const MImageWidget &)
MImageWidgetoperator= (const MImageWidget &)
virtual ~MImageWidget ()
void setImage (const QString &id, const QSize &size)
QString image () const
QString imageId () const
QSize imageSize () const
const QPixmappixmap () const
void setZoomFactor (qreal factor)
void setZoomFactor (qreal fx, qreal fy)
void zoomFactor (qreal *fx, qreal *fy) const
void zoomIn ()
void zoomOut ()
void setAspectRatioMode (Qt::AspectRatioMode mode)
Qt::AspectRatioMode aspectRatioMode () const
void setCrop (const QRectF &rect)
QRectF crop () const

Properties

QRectF crop
Qt::AspectRatioMode aspectRatioMode
QString image

Detailed Description

MImageWidget is a simple widget to show image.

Overview

Image allows the placement of images onto the UI. Images are generally non-interactive elements. Various single and multiple touch interactions can be added to an Image component if so wanted.

Image supports scale, crop, zoom operations.

Usage guidelines

NOTE: The images passed to MImageWidget are converted internally to OpenGL textures, thus their maximum size is limited by the GPU driver. Consult the documentation of the GPU unit for the actual maximum texture size. If the image exceeds the maximum supported size, it shall not be drawn.

Images can be used by themselves to decorate the UI (background images, frames etc.) and also combined as part of other components (grids, lists, buttons etc.).

If the Image has interactive elements, the touch area size of the interactive element needs to be specified. The area can occupy the entire Image, and/or it can also fall outside the Image: for instance in the case of an Image with a label, they are combined to form one interactive area. An Image can be on top or below of other images and other components (determined by the z-order).

MImageWidget provides sizeHint(), default size will be the size which defined in CSS. If not defined in CSS, will be the size of image which added into MImage.

MImageWidget can show border around the image, you can custom border in CSS. The border will work as a decoration and hint. Any cropped side will have no border.

Example codes

MImageWidget can show image from theme:

        MImageWidget* image = new MImageWidget("icon");

Also can get image with request size from theme:

        MImageWidget* image = new MImageWidget();
        image->setImage("icon", QSize(64,64));

Or set image directly

        QImage img(path);
        MImageWidget* image = new MImageWidget(&img);
Attention:
By default image will be shown full of the widget in Qt::KeepAspectRatio mode. You can change the mode use setAspectRatioMode(Qt::IgnoreAspectRatio)
        QImage img(path);
        MImageWidget* image = new MImageWidget(&img);
        image->setAspectRatioMode(Qt::IgnoreAspectRatio);
See also:
MImageWidgetModel MImageWidgetStyle

Constructor & Destructor Documentation

MImageWidget::MImageWidget ( QGraphicsItem parent = 0  ) 

Constructs a image with a parent.

Parameters:
parent Parent object.
MImageWidget::MImageWidget ( const QString id,
QGraphicsItem parent = 0 
) [explicit]
MImageWidget::MImageWidget ( const QImage image,
QGraphicsItem parent = 0 
) [explicit]
MImageWidget::MImageWidget ( const QPixmap pixmap,
QGraphicsItem parent = 0 
) [explicit]
MImageWidget::MImageWidget ( const MImageWidget other  ) 

Copy constructor.

MImageWidget::~MImageWidget (  )  [virtual]

Destroys the image.


Member Function Documentation

Qt::AspectRatioMode MImageWidget::aspectRatioMode (  )  const

Get image aspect ratio mode.

QRectF MImageWidget::crop (  )  const

Get the crop rectangle.

Deprecated:
There is no replacing functionality
QString MImageWidget::image (  )  const

Get the image id.

Deprecated:
Use the MImageWidget::imageId();
QString MImageWidget::imageId (  )  const

Get the image id.

QSize MImageWidget::imageSize (  )  const

Get the origin size of the image.

MImageWidget & MImageWidget::operator= ( const MImageWidget other  ) 

Assigns other to this MImageWidget and returns a reference to this MImageWidget.

const QPixmap * MImageWidget::pixmap (  )  const

Get the pointer of pixmap.

Deprecated:
void MImageWidget::setAspectRatioMode ( Qt::AspectRatioMode  mode  ) 

Set image zoom AspectRatioMode.

Parameters:
mode defines what happens to the aspect ratio when zoom image.
void MImageWidget::setCrop ( const QRectF rect  ) 

Set image cropped to this recangle.

Parameters:
size crop section rectangle
Deprecated:
There is no replacing functionality
void MImageWidget::setImage ( const QString id,
const QSize size 
)

Sets the logical ID associated with this image to id.

The graphics specified by the ID will be exactly of the specified size, and will stretch to fill the image widget.

void MImageWidget::setImage ( const QString id  )  [slot]

Sets the logical ID associated with this image to id.

Whatever size the graphics happens to be in the theme will be used. The graphics is then scaled to fit the image widget. Unless you know that the themed graphic is exactly of the right size, you must use the setImage(const QString &id, const QSize &size) method instead.

void MImageWidget::setImage ( const QImage image  )  [slot]

Set a QImage into MImage.

void MImageWidget::setPixmap ( const QPixmap pixmap  )  [slot]

Set a QPixmap into MImage.

void MImageWidget::setZoomFactor ( qreal  fx,
qreal  fy 
)

Set image width and height zoom factor.

Parameters:
fx image width zoom factor
fy image height zoom factor If fx not equals fy, will set zoom ratio mode to Qt::IgnoreAspectRatio automatic
void MImageWidget::setZoomFactor ( qreal  factor  ) 

Set image two aspect ratio factors to one value.

Parameters:
factor image zoom factor
void MImageWidget::zoomFactor ( qreal *  fx,
qreal *  fy 
) const

This function get image zoom factor The parameters point to values stored in float.

If any of the pointers is 0, that value will not be updated.

Deprecated:
There is no replacing functionality
void MImageWidget::zoomIn (  ) 

Zoom in image.

Deprecated:
There is no replacing functionality
void MImageWidget::zoomOut (  ) 

Zoom out image.

Deprecated:
There is no replacing functionality

Property Documentation

Qt::AspectRatioMode MImageWidget::aspectRatioMode [read, write]
MImageWidget::crop [read, write]
QString MImageWidget::image [read, write]

Copyright © 2010 Nokia Corporation
MeeGo Touch