QChartView Class | Qt Charts 5.7

Qt 5.7 | Qt Charts | C++ Classes | QChartView

Qt 5.7.1 Reference Documentation

# QChartView Class

Standalone charting widget. More...

Header: | #include <QChartView>
Inherits: | QGraphicsView

- List of all members, including inherited members

## 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)

- 78 public functions inherited from QGraphicsView
- 20 public functions inherited from QAbstractScrollArea
- 14 public functions inherited from QFrame
- 213 public functions inherited from QWidget

## Reimplemented Protected Functions

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

- 24 protected functions inherited from QGraphicsView
- 20 protected functions inherited from QAbstractScrollArea
- 4 protected functions inherited from QFrame
- 35 protected functions inherited from QWidget

### Additional Inherited Members

- 13 properties inherited from QGraphicsView
- 3 properties inherited from QAbstractScrollArea
- 6 properties inherited from QFrame
- 58 properties inherited from QWidget
- 3 public slots inherited from QGraphicsView
- 19 public slots inherited from QWidget
- 1 signal inherited from QGraphicsView
- 3 signals inherited from QWidget
- 5 static public members inherited from QWidget
- 24 protected functions inherited from QGraphicsView
- 20 protected functions inherited from QAbstractScrollArea
- 4 protected functions inherited from QFrame
- 35 protected functions inherited from QWidget
- 1 protected slot inherited from QGraphicsView
- 1 protected slot inherited from QWidget

## 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

Constant | Value
--- | ---
`QChartView::NoRubberBand` | `0x0`
`QChartView::VerticalRubberBand` | `0x1`
`QChartView::HorizontalRubberBand` | `0x2`
`QChartView::RectangleRubberBand` | `0x3`

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().