KD Reports API Documentation 2.2
Loading...
Searching...
No Matches
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 ImageElement &other)
 
 ImageElement (const QImage &image)
 
 ImageElement (const QPixmap &pixmap)
 
 ~ImageElement () override
 
void build (ReportBuilder &) const override
 
Elementclone () const override
 
bool fitToPage () const
 
qreal height () const
 
QString id () const
 
QImage image () const
 
ImageElementoperator= (const ImageElement &other)
 
QPixmap pixmap () const
 
void setFitToPage ()
 
void setHeight (qreal height, Unit unit=Millimeters)
 
void setId (const QString &id)
 
void setImage (const QImage &image)
 
void setPixmap (const QPixmap &pixmap)
 
void setUnit (Unit unit)
 
void setWidth (qreal width, Unit unit=Millimeters)
 
Unit unit () const
 
qreal width () const
 
- Public Member Functions inherited from KDReports::Element
virtual ~Element ()
 
QBrush background () const
 
void setBackground (const QBrush &brush)
 

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.

Definition at line 29 of file KDReportsImageElement.h.

Constructor & Destructor Documentation

◆ ImageElement() [1/3]

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.

Definition at line 35 of file KDReportsImageElement.cpp.

References pixmap(), and setPixmap().

◆ ImageElement() [2/3]

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

Definition at line 41 of file KDReportsImageElement.cpp.

References image(), and setImage().

◆ ~ImageElement()

KDReports::ImageElement::~ImageElement ( )
override

Destroys this image element.

Definition at line 62 of file KDReportsImageElement.cpp.

◆ ImageElement() [3/3]

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

Copies a image element.

Definition at line 47 of file KDReportsImageElement.cpp.

Member Function Documentation

◆ build()

void KDReports::ImageElement::build ( ReportBuilder builder) const
overridevirtual

◆ clone()

KDReports::Element * KDReports::ImageElement::clone ( ) const
overridevirtual

Implements KDReports::Element.

Definition at line 197 of file KDReportsImageElement.cpp.

◆ fitToPage()

bool KDReports::ImageElement::fitToPage ( ) const
Returns
if the image be scaled to fills the page.
Since
1.4

Definition at line 123 of file KDReportsImageElement.cpp.

◆ height()

qreal KDReports::ImageElement::height ( ) const
Returns
the height of the image.
Since
1.4

Definition at line 111 of file KDReportsImageElement.cpp.

◆ id()

QString KDReports::ImageElement::id ( ) const
Returns
the ID associated with this image element.
Since
1.4

Definition at line 192 of file KDReportsImageElement.cpp.

◆ image()

QImage KDReports::ImageElement::image ( ) const
Returns
the image.
Since
1.4

Definition at line 85 of file KDReportsImageElement.cpp.

Referenced by ImageElement().

◆ operator=()

KDReports::ImageElement & KDReports::ImageElement::operator= ( const ImageElement other)

Copies the data from another image element.

Definition at line 53 of file KDReportsImageElement.cpp.

References KDReports::Element::operator=().

◆ pixmap()

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

Definition at line 74 of file KDReportsImageElement.cpp.

Referenced by ImageElement().

◆ setFitToPage()

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

Definition at line 116 of file KDReportsImageElement.cpp.

◆ setHeight()

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

Definition at line 103 of file KDReportsImageElement.cpp.

◆ setId()

void KDReports::ImageElement::setId ( const QString id)

Set the ID associated with this image element.

Since
1.4

Definition at line 187 of file KDReportsImageElement.cpp.

◆ setImage()

void KDReports::ImageElement::setImage ( const QImage image)

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

Definition at line 79 of file KDReportsImageElement.cpp.

References QVariant::fromValue(), and QImage::size().

Referenced by ImageElement().

◆ setPixmap()

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

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

Definition at line 66 of file KDReportsImageElement.cpp.

References QVariant::fromValue(), QPixmap::size(), and QPixmap::toImage().

Referenced by ImageElement().

◆ setUnit()

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

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

Since
1.5

Definition at line 207 of file KDReportsImageElement.cpp.

◆ setWidth()

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.

Definition at line 90 of file KDReportsImageElement.cpp.

◆ unit()

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

Definition at line 202 of file KDReportsImageElement.cpp.

◆ width()

qreal KDReports::ImageElement::width ( ) const
Returns
the width of the image.
Since
1.4

Definition at line 98 of file KDReportsImageElement.cpp.


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

© 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/
Generated on Sun Apr 14 2024 00:04:57 for KD Reports API Documentation by doxygen 1.9.8