KD Reports API Documentation  2.2
Public Member Functions | List of all members
KDReports::ChartElement Class Reference

#include <KDReportsChartElement.h>

Inheritance diagram for KDReports::ChartElement:
KDReports::Element

Public Member Functions

 ChartElement (const ChartElement &other)
 
 ChartElement (const QString &modelKey)
 
 ChartElement (KDChart::Chart *chart)
 
 ChartElement (QAbstractItemModel *tableModel)
 
 ~ChartElement () override
 
void build (ReportBuilder &) const override
 
Elementclone () const override
 
ChartElementoperator= (const ChartElement &other)
 
void setChart (KDChart::Chart *chart)
 
void setModelKey (const QString &modelKey)
 
void setSize (qreal width, qreal height, Unit unit=Millimeters)
 
void setTableModel (QAbstractItemModel *tableModel)
 
QSizeF size () const
 
Unit unit () 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::ChartElement class represents a chart in the report. The data is provided by a QAbstractItemModel.

Definition at line 35 of file KDReportsChartElement.h.

Constructor & Destructor Documentation

◆ ChartElement() [1/4]

KDReports::ChartElement::ChartElement ( QAbstractItemModel *  tableModel)
explicit

Creates a chart element from the given table model.

Definition at line 62 of file KDReportsChartElement.cpp.

◆ ChartElement() [2/4]

KDReports::ChartElement::ChartElement ( const QString &  modelKey)
explicit

Creates a chart element that does not have an associated model yet. The association will be done later using the model key.

See also
KDReports::Report::associateModel()

Definition at line 68 of file KDReportsChartElement.cpp.

References KDReports::modelForKey().

◆ ChartElement() [3/4]

KDReports::ChartElement::ChartElement ( KDChart::Chart *  chart)
explicit

Creates a chart element from the given chart.

The chart's ownership is NOT transferred. It is very important that the chart exists at least as long as the report object exists.

Since
1.3

Definition at line 75 of file KDReportsChartElement.cpp.

◆ ~ChartElement()

KDReports::ChartElement::~ChartElement ( )
override

Destroys this chart element.

Definition at line 102 of file KDReportsChartElement.cpp.

◆ ChartElement() [4/4]

KDReports::ChartElement::ChartElement ( const ChartElement other)

Copies a chart element.

Definition at line 87 of file KDReportsChartElement.cpp.

Member Function Documentation

◆ build()

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

Implements KDReports::Element.

Definition at line 124 of file KDReportsChartElement.cpp.

References KDReports::ReportBuilder::cursor().

◆ clone()

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

Implements KDReports::Element.

Definition at line 173 of file KDReportsChartElement.cpp.

◆ operator=()

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

Copies the data from another chart element.

Definition at line 93 of file KDReportsChartElement.cpp.

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

◆ setChart()

void KDReports::ChartElement::setChart ( KDChart::Chart *  chart)

Sets the chart to use in this chart element. Useful for associating a chart to a ChartElement from XmlElementHandler.

The chart's ownership is NOT transferred. It is very important that the chart exists at least as long as the report object exists.

Since
1.3

Definition at line 106 of file KDReportsChartElement.cpp.

◆ setModelKey()

void KDReports::ChartElement::setModelKey ( const QString &  modelKey)

set the model key associated with this element

Since
1.4

Definition at line 188 of file KDReportsChartElement.cpp.

References KDReports::modelForKey().

◆ setSize()

void KDReports::ChartElement::setSize ( qreal  width,
qreal  height,
Unit  unit = Millimeters 
)

Sets the size of the chart. The default size is a 100% of the page width, for both width and height.

To set a chart size that adapts well to any page size, use Percent as unit. setSize(50, 75, Percent) means that the width will be half of the page width (without margins), and the height will always be 1.5 times the width (preserving the ratio between 50 and 75). This feature (Percent) leads to slightly worse results on screen at 100% zoom, due to scaling happening even at that size, but the printed report should be fine.

Definition at line 118 of file KDReportsChartElement.cpp.

◆ setTableModel()

void KDReports::ChartElement::setTableModel ( QAbstractItemModel *  tableModel)

set the model associated with this element

Since
1.4

Definition at line 194 of file KDReportsChartElement.cpp.

◆ size()

QSizeF KDReports::ChartElement::size ( ) const
Returns
the size of the chart, use unit() to know the size unit
Since
1.4

Definition at line 178 of file KDReportsChartElement.cpp.

◆ unit()

KDReports::Unit KDReports::ChartElement::unit ( ) const
Returns
the size unit
Since
1.4

Definition at line 183 of file KDReportsChartElement.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 by doxygen 1.9.1