QChartView Class

Standalone charting widget. More...

Header: #include <QChartView>
Inherits: QGraphicsView

Public Types

enum RubberBand { NoRubberBand, VerticalRubberBand, HorizontalRubberBand, RectangleRubberBand }
flags RubberBands

Public Functions

QChartView(QWidget *parent = Q_NULLPTR)
QChartView(QChart *chart, QWidget *parent = Q_NULLPTR)
~QChartView()
QChart *chart() const
RubberBands rubberBand() const
void setChart(QChart *chart)
void setRubberBand(const RubberBands &rubberBand)

Reimplemented Protected Functions

virtual void mouseMoveEvent(QMouseEvent *event)
virtual void mousePressEvent(QMouseEvent *event)
virtual void mouseReleaseEvent(QMouseEvent *event)
virtual void resizeEvent(QResizeEvent *event)

Additional Inherited Members

Detailed Description

Standalone charting widget.

QChartView is a standalone widget that can display charts. It does not require separate QGraphicsScene to work. If you want to display a chart in your existing QGraphicsScene, you need to use the QChart (or QPolarChart) class instead.

See also QChart and QPolarChart.

Member Type Documentation

enum QChartView::RubberBand
flags QChartView::RubberBands

This enum describes the different types of rubber bands that can be used for zoom rect selection

ConstantValue
QChartView::NoRubberBand0x0
QChartView::VerticalRubberBand0x1
QChartView::HorizontalRubberBand0x2
QChartView::RectangleRubberBand0x3

The RubberBands type is a typedef for QFlags<RubberBand>. It stores an OR combination of RubberBand values.

Member Function Documentation

QChartView::QChartView(QWidget *parent = Q_NULLPTR)

Constructs a chartView object with parent parent.

QChartView::QChartView(QChart *chart, QWidget *parent = Q_NULLPTR)

Constructs a chartview object with parent parent to display a chart. Ownership of the chart is passed to chartview.

QChartView::~QChartView()

Destroys the chartview object and the associated chart.

QChart *QChartView::chart() const

Returns the pointer to the associated chart.

See also setChart().

[virtual protected] void QChartView::mouseMoveEvent(QMouseEvent *event)

Reimplemented from QWidget::mouseMoveEvent().

If the rubber band rectange has been displayed in pressEvent then event data is used to update the rubber band geometry. Otherwise the default QGraphicsView::mouseMoveEvent implementation is called.

[virtual protected] void QChartView::mousePressEvent(QMouseEvent *event)

Reimplemented from QWidget::mousePressEvent().

If Left mouse button is pressed and the rubber band is enabled the event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area. If different mouse button is pressed and/or the rubber band is disabled then the event is passed to QGraphicsView::mousePressEvent() implementation.

[virtual protected] void QChartView::mouseReleaseEvent(QMouseEvent *event)

Reimplemented from QWidget::mouseReleaseEvent().

If left mouse button is released and the rubber band is enabled then event is accepted and the view is zoomed into the rect specified by the rubber band. If it is a right mouse button event then the view is zoomed out.

[virtual protected] void QChartView::resizeEvent(QResizeEvent *event)

Reimplemented from QWidget::resizeEvent().

Resizes and updates the chart area using the event data

RubberBands QChartView::rubberBand() const

Returns the rubber band flags that are currently being used by the widget.

See also setRubberBand().

void QChartView::setChart(QChart *chart)

Sets the current chart to chart. Ownership of the new chart is passed to chartview and ownership of the previous chart is released.

To avoid memory leaks users need to make sure the previous chart is deleted.

See also chart().

void QChartView::setRubberBand(const RubberBands &rubberBand)

Sets the rubber band flags to rubberBand. Selected flags determine the way zooming is performed.

Note: Rubber band zooming is not supported for polar charts.

See also rubberBand().

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.