KD Reports  1.8
Public Member Functions | List of all members
KDReports::ImageElement Class Reference

#include <KDReportsImageElement.h>

Inheritance diagram for KDReports::ImageElement:
Inheritance graph
[legend]
Collaboration diagram for KDReports::ImageElement:
Collaboration graph
[legend]

Public Member Functions

 ImageElement (const QPixmap &pixmap)
 
 ImageElement (const QImage &image)
 
virtual ~ImageElement ()
 
void setPixmap (const QPixmap &pixmap)
 
QPixmap pixmap () const
 
void setImage (const QImage &image)
 
QImage image () const
 
 ImageElement (const ImageElement &other)
 
ImageElementoperator= (const ImageElement &other)
 
void setWidth (qreal width, Unit unit=Millimeters)
 
qreal width () const
 
void setHeight (qreal height, Unit unit=Millimeters)
 
qreal height () const
 
Unit unit () const
 
void setUnit (Unit unit)
 
void setFitToPage ()
 
bool fitToPage () const
 
void setId (const QString &id)
 
QString id () const
 
- Public Member Functions inherited from KDReports::Element
virtual ~Element ()
 
void setBackground (const QBrush &brush)
 
QBrush background () const
 

Additional Inherited Members

- Protected Member Functions inherited from KDReports::Element
 Element ()
 
 Element (const Element &other)
 
Elementoperator= (const Element &other)
 

Detailed Description

The KDReports::ImageElement class represents an image in the report.

Constructor & Destructor Documentation

KDReports::ImageElement::ImageElement ( const QPixmap &  pixmap)
explicit

Creates a image element from the given pixmap. This constructor can only be used in the GUI thread.

KDReports::ImageElement::ImageElement ( const QImage &  image)
explicit

Creates a image element from the given image. This constructor can be used from secondary threads as well.

Since
1.3
virtual KDReports::ImageElement::~ImageElement ( )
virtual

Destroys this image element.

KDReports::ImageElement::ImageElement ( const ImageElement other)

Copies a image element.

Member Function Documentation

bool KDReports::ImageElement::fitToPage ( ) const
Returns
if the image be scaled to fills the page.
Since
1.4
qreal KDReports::ImageElement::height ( ) const
Returns
the height of the image.
Since
1.4
QString KDReports::ImageElement::id ( ) const
Returns
the ID associated with this image element.
Since
1.4
QImage KDReports::ImageElement::image ( ) const
Returns
the image.
Since
1.4
ImageElement& KDReports::ImageElement::operator= ( const ImageElement other)

Copies the data from another image element.

QPixmap KDReports::ImageElement::pixmap ( ) const
Returns
the pixmap.
Since
1.4
void KDReports::ImageElement::setFitToPage ( )

Requests that the image be scaled so that it fills the page as much as possible, while still preserving aspect ratio. This is mutually exclusive with setHeight/setWidth.

Since
1.1
void KDReports::ImageElement::setHeight ( qreal  height,
Unit  unit = Millimeters 
)

Sets the height of the image. The width of the image is calculated so that the aspect ratio is preserved. This is mutually exclusive with setWidth().

Since
1.1
void KDReports::ImageElement::setId ( const QString &  id)

Set the ID associated with this image element.

Since
1.4
void KDReports::ImageElement::setImage ( const QImage &  image)

Sets a new image for this image element. This replaces the pixmap or image set previously.

void KDReports::ImageElement::setPixmap ( const QPixmap &  pixmap)

Sets the pixmap for this image element. This replaces the pixmap or image set previously.

void KDReports::ImageElement::setUnit ( Unit  unit)

Set the unit for the image size (percent or millimeters).

Since
1.5
void KDReports::ImageElement::setWidth ( qreal  width,
Unit  unit = Millimeters 
)

Sets the width of the image. The height of the image is calculated so that the aspect ratio is preserved.

The default size, if setWidth is not called, is the pixmap's size in pixels, which might lead to a different size depending on the resolution of the output device but avoids any resizing. On the other hand, setWidth makes sure that the layout of the document is always the same by resizing the pixmap if necessary.

For an image that should take half of the width of the page, call setWidth(50, KDReports::Percent).

Note that images inside table cells still have their width relative to the page, not to the cell. For instance setWidth(10, KDReports::Percent) means that the image width will be 10% of the page width, not 10% of the containing cell's width.

Unit KDReports::ImageElement::unit ( ) const
Returns
the unit for the image size (percent or millimeters).
Since
1.4
qreal KDReports::ImageElement::width ( ) const
Returns
the width of the image.
Since
1.4

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

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/

https://www.kdab.com/development-resources/qt-tools/kd-reports/