KD Chart 2  [rev.2.7]
Public Types | Public Slots | Public Member Functions | List of all members
KDChart::Widget Class Reference

The KD Chart widget for usage without Model/View. More...

#include <KDChartWidget.h>

Inheritance diagram for KDChart::Widget:
Inheritance graph
[legend]
Collaboration diagram for KDChart::Widget:
Collaboration graph
[legend]

Public Types

enum  ChartType {
  NoType,
  Bar,
  Line,
  Plot,
  Pie,
  Ring,
  Polar
}
 
enum  SubType {
  Normal,
  Stacked,
  Percent,
  Rows
}
 Sub type values, matching the values defines for the respective Diagram classes. More...
 

Public Slots

void setGlobalLeading (int left, int top, int right, int bottom)
 Sets all global leadings (borders). More...
 
void setGlobalLeadingBottom (int leading)
 Sets the bottom leading (border). More...
 
void setGlobalLeadingLeft (int leading)
 Sets the left leading (border). More...
 
void setGlobalLeadingRight (int leading)
 Sets the right leading (border). More...
 
void setGlobalLeadingTop (int leading)
 Sets the top leading (border). More...
 
void setSubType (SubType subType)
 Sets the type of the chart without changing the main type. More...
 
void setType (ChartType chartType, SubType subType=Normal)
 Sets the type of the chart. More...
 

Public Member Functions

void addHeaderFooter (const QString &text, HeaderFooter::HeaderFooterType type, Position position)
 Adds a new header/footer with the given text to the position. More...
 
void addHeaderFooter (HeaderFooter *header)
 Adds the existing header / footer object header. More...
 
void addLegend (Position position)
 Adds an empty legend on the given position. More...
 
void addLegend (Legend *legend)
 Adds a new, already existing, legend. More...
 
QList< HeaderFooter * > allHeadersFooters ()
 Returns a list with all headers. More...
 
QList< Legend * > allLegends ()
 Returns a list with all legends. More...
 
BarDiagrambarDiagram ()
 If the current diagram is a BarDiagram, it is returnd; otherwise 0 is returned. More...
 
AbstractCoordinatePlanecoordinatePlane ()
 Returns a pointer to the current coordinate plane. More...
 
AbstractDiagramdiagram ()
 Returns a pointer to the current diagram. More...
 
HeaderFooterfirstHeaderFooter ()
 Returns the first of all headers. More...
 
int globalLeadingBottom () const
 Returns the bottom leading (border). More...
 
int globalLeadingLeft () const
 Returns the left leading (border). More...
 
int globalLeadingRight () const
 Returns the right leading (border). More...
 
int globalLeadingTop () const
 Returns the top leading (border). More...
 
Legendlegend ()
 Returns the first of all legends. More...
 
LineDiagramlineDiagram ()
 If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned. More...
 
PieDiagrampieDiagram ()
 If the current diagram is a Plotter, it is returnd; otherwise 0 is returned. More...
 
Plotterplotter ()
 If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned. More...
 
PolarDiagrampolarDiagram ()
 If the current diagram is a PolarDiagram, it is returnd; otherwise 0 is returned. More...
 
void replaceHeaderFooter (HeaderFooter *header, HeaderFooter *oldHeader=0)
 Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet. More...
 
void replaceLegend (Legend *legend, Legend *oldLegend=0)
 
void resetData ()
 Resets all data. More...
 
RingDiagramringDiagram ()
 If the current diagram is a RingDiagram, it is returnd; otherwise 0 is returned. More...
 
void setDataCell (int row, int column, qreal data)
 Sets the Y value data for a given cell. More...
 
void setDataCell (int row, int column, QPair< qreal, qreal > data)
 Sets the data for a given column using an (X, Y) QPair of qreals. More...
 
void setDataset (int column, const QVector< qreal > &data, const QString &title=QString())
 Sets the data in the given column using a QVector of qreal for the Y values. More...
 
void setDataset (int column, const QVector< QPair< qreal, qreal > > &data, const QString &title=QString())
 Sets the data in the given column using a QVector of QPairs of qreal for the (X, Y) values. More...
 
SubType subType () const
 Returns the sub-type of the chart. More...
 
void takeHeaderFooter (HeaderFooter *header)
 Remove the header (or footer, resp.) from the widget, without deleting it. More...
 
void takeLegend (Legend *legend)
 
ChartType type () const
 Returns the type of the chart. More...
 
 Widget (QWidget *parent=0)
 Standard Qt-style Constructor. More...
 
 ~Widget () override
 Destructor. More...
 

Detailed Description

The KD Chart widget for usage without Model/View.

If you want to use KD Chart with Model/View, use KDChart::Chart instead.

Definition at line 60 of file KDChartWidget.h.

Member Enumeration Documentation

Enumerator
NoType 
Bar 
Line 
Plot 
Pie 
Ring 
Polar 

Definition at line 208 of file KDChartWidget.h.

Sub type values, matching the values defines for the respective Diagram classes.

Enumerator
Normal 
Stacked 
Percent 
Rows 

Definition at line 214 of file KDChartWidget.h.

Constructor & Destructor Documentation

Widget::Widget ( QWidget parent = 0)
explicit

Standard Qt-style Constructor.

Constructor.

Creates a new widget with all data initialized empty.

Parameters
parentthe widget parent; passed on to QWidget

Definition at line 76 of file KDChartWidget.cpp.

References Line, and setType().

Widget::~Widget ( )
override

Destructor.

Definition at line 87 of file KDChartWidget.cpp.

Member Function Documentation

void Widget::addHeaderFooter ( const QString &  text,
HeaderFooter::HeaderFooterType  type,
Position  position 
)

Adds a new header/footer with the given text to the position.

Definition at line 265 of file KDChartWidget.cpp.

References d, KDChart::HeaderFooter::setPosition(), KDChart::TextLayoutItem::setText(), and KDChart::HeaderFooter::setType().

void Widget::addHeaderFooter ( HeaderFooter header)

Adds the existing header / footer object header.

Adds an existing header / footer object.

See also
replaceHeaderFooter, takeHeaderFooter

Definition at line 279 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

void Widget::addLegend ( Position  position)

Adds an empty legend on the given position.

Definition at line 315 of file KDChartWidget.cpp.

References d, diagram(), legend(), and KDChart::Legend::setPosition().

void Widget::addLegend ( Legend legend)

Adds a new, already existing, legend.

Definition at line 325 of file KDChartWidget.cpp.

References d, diagram(), and KDChart::Legend::setDiagram().

QList< KDChart::HeaderFooter * > Widget::allHeadersFooters ( )

Returns a list with all headers.

Definition at line 257 of file KDChartWidget.cpp.

References d.

QList< KDChart::Legend * > Widget::allLegends ( )

Returns a list with all legends.

Definition at line 307 of file KDChartWidget.cpp.

References d.

BarDiagram * Widget::barDiagram ( )

If the current diagram is a BarDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 352 of file KDChartWidget.cpp.

References diagram().

AbstractCoordinatePlane * Widget::coordinatePlane ( )

Returns a pointer to the current coordinate plane.

Definition at line 377 of file KDChartWidget.cpp.

References d.

Referenced by diagram(), and setType().

AbstractDiagram * Widget::diagram ( )
KDChart::HeaderFooter * Widget::firstHeaderFooter ( )

Returns the first of all headers.

Definition at line 249 of file KDChartWidget.cpp.

References d.

int Widget::globalLeadingBottom ( ) const

Returns the bottom leading (border).

Definition at line 241 of file KDChartWidget.cpp.

References d.

int Widget::globalLeadingLeft ( ) const

Returns the left leading (border).

Definition at line 193 of file KDChartWidget.cpp.

References d.

int Widget::globalLeadingRight ( ) const

Returns the right leading (border).

Definition at line 225 of file KDChartWidget.cpp.

References d.

int Widget::globalLeadingTop ( ) const

Returns the top leading (border).

Definition at line 209 of file KDChartWidget.cpp.

References d.

KDChart::Legend * Widget::legend ( )

Returns the first of all legends.

Definition at line 299 of file KDChartWidget.cpp.

References d.

Referenced by addLegend().

LineDiagram * Widget::lineDiagram ( )

If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 356 of file KDChartWidget.cpp.

References diagram().

PieDiagram * Widget::pieDiagram ( )

If the current diagram is a Plotter, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 364 of file KDChartWidget.cpp.

References diagram().

Plotter * Widget::plotter ( )

If the current diagram is a LineDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Note
Do not use lineDiagram for multi-dimensional diagrams, but use plotter instead
See also
plotter

Definition at line 360 of file KDChartWidget.cpp.

References diagram().

PolarDiagram * Widget::polarDiagram ( )

If the current diagram is a PolarDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 372 of file KDChartWidget.cpp.

References diagram().

void Widget::replaceHeaderFooter ( HeaderFooter header,
HeaderFooter oldHeader = 0 
)

Replaces the old header (or footer, resp.), or appends the new header or footer, it there is none yet.

Parameters
headerThe header or footer to be used instead of the old one. This parameter must not be zero, or the method will do nothing.
oldHeaderThe header or footer to be removed by the new one. This header or footer will be deleted automatically. If the parameter is omitted, the very first header or footer will be replaced. In case, there was no header and no footer yet, the new header or footer will just be added.
Note
If you want to re-use the old header or footer, call takeHeaderFooter and addHeaderFooter, instead of using replaceHeaderFooter.
See also
addHeaderFooter, takeHeaderFooter

Definition at line 285 of file KDChartWidget.cpp.

References d, and KDChart::HeaderFooter::setParent().

void Widget::replaceLegend ( Legend legend,
Legend oldLegend = 0 
)

Definition at line 332 of file KDChartWidget.cpp.

References d, diagram(), and KDChart::Legend::setDiagram().

void Widget::resetData ( )

Resets all data.

Definition at line 168 of file KDChartWidget.cpp.

References d.

RingDiagram * Widget::ringDiagram ( )

If the current diagram is a RingDiagram, it is returnd; otherwise 0 is returned.

This function provides type-safe casting.

Definition at line 368 of file KDChartWidget.cpp.

References diagram().

void Widget::setDataCell ( int  row,
int  column,
qreal  data 
)

Sets the Y value data for a given cell.

Definition at line 136 of file KDChartWidget.cpp.

References d.

void Widget::setDataCell ( int  row,
int  column,
QPair< qreal, qreal >  data 
)

Sets the data for a given column using an (X, Y) QPair of qreals.

Definition at line 149 of file KDChartWidget.cpp.

References d.

void Widget::setDataset ( int  column,
const QVector< qreal > &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of qreal for the Y values.

Definition at line 96 of file KDChartWidget.cpp.

References d.

void Widget::setDataset ( int  column,
const QVector< QPair< qreal, qreal > > &  data,
const QString &  title = QString() 
)

Sets the data in the given column using a QVector of QPairs of qreal for the (X, Y) values.

Definition at line 114 of file KDChartWidget.cpp.

References d.

void Widget::setGlobalLeading ( int  left,
int  top,
int  right,
int  bottom 
)
slot

Sets all global leadings (borders).

Definition at line 177 of file KDChartWidget.cpp.

References d.

void Widget::setGlobalLeadingBottom ( int  leading)
slot

Sets the bottom leading (border).

Definition at line 233 of file KDChartWidget.cpp.

References d.

void Widget::setGlobalLeadingLeft ( int  leading)
slot

Sets the left leading (border).

Definition at line 185 of file KDChartWidget.cpp.

References d.

void Widget::setGlobalLeadingRight ( int  leading)
slot

Sets the right leading (border).

Definition at line 217 of file KDChartWidget.cpp.

References d.

void Widget::setGlobalLeadingTop ( int  leading)
slot

Sets the top leading (border).

Definition at line 201 of file KDChartWidget.cpp.

References d.

void Widget::setSubType ( SubType  subType)
slot

Sets the type of the chart without changing the main type.

Make sure to use a sub-type that matches the main type, so e.g. setting sub-type Rows makes sense for Bar charts only, and it will be ignored for all other chart types.

See also
KDChartBarDiagram::BarType, KDChartLineDiagram::LineType
KDChartPieDiagram::PieType, KDChartRingDiagram::RingType
KDChartPolarDiagram::PolarType

Definition at line 481 of file KDChartWidget.cpp.

References diagram(), KDChart::BarDiagram::Normal, KDChart::Plotter::Normal, KDChart::LineDiagram::Normal, Normal, KDChart::BarDiagram::Percent, KDChart::Plotter::Percent, KDChart::LineDiagram::Percent, Percent, KDChart::BarDiagram::Rows, Rows, KDChart::BarDiagram::Stacked, KDChart::LineDiagram::Stacked, and Stacked.

Referenced by setType().

void Widget::setType ( ChartType  chartType,
SubType  subType = Normal 
)
slot
Widget::SubType Widget::subType ( ) const
void Widget::takeHeaderFooter ( HeaderFooter header)

Remove the header (or footer, resp.) from the widget, without deleting it.

The chart no longer owns the header or footer, so it is the caller's responsibility to delete the header or footer.

See also
addHeaderFooter, replaceHeaderFooter

Definition at line 291 of file KDChartWidget.cpp.

References d.

void Widget::takeLegend ( Legend legend)

Definition at line 339 of file KDChartWidget.cpp.

References d.

Widget::ChartType Widget::type ( ) const

Returns the type of the chart.

Definition at line 514 of file KDChartWidget.cpp.

References Bar, diagram(), Line, NoType, Pie, Plot, Polar, and Ring.

Referenced by setType(), and subType().


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-chart/