QChartView 类

QChartView 是可以显示图表的独立 Widget。 更多...

头: #include <QChartView>
继承: QGraphicsView

公共类型

(从 6.2 起) enum RubberBand { NoRubberBand, VerticalRubberBand, HorizontalRubberBand, RectangleRubberBand, ClickThroughRubberBand }
flags RubberBands

公共函数

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

重实现保护函数

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

详细描述

图表视图不要求 QGraphicsScene 对象去工作。要显示图表在现有 QGraphicsScene QChart or QPolarChart 类应该被使用以取而代之。

另请参阅 QChart and QPolarChart .

成员类型文档编制

[since 6.2] enum QChartView:: RubberBand
flags QChartView:: RubberBands

This enum describes the different types of rubber band effects that can be applied to the rectangular zooming area.

常量 描述
QChartView::NoRubberBand 0x0 No zooming area is specified, and therefore zooming is not enabled.
QChartView::VerticalRubberBand 0x1 The rubber band is locked to the size of the chart horizontally and can be pulled vertically to specify the zooming area.
QChartView::HorizontalRubberBand 0x2 The rubber band is locked to the size of the chart vertically and can be pulled horizontally to specify the zooming area.
QChartView::RectangleRubberBand 0x3 The rubber band is fixed to the point that was clicked and can be pulled both vertically and horizontally.
QChartView::ClickThroughRubberBand 0x80 An option on the above rubber band choices that allows left clicks to be passed on to chart items if those chart items accept clicks. To select this, OR it with one of the rubber band selection modes.

该枚举在 Qt 6.2 引入。

RubberBands 类型是 typedef 对于 QFlags <RubberBand>. It stores an OR combination of RubberBand values.

成员函数文档编制

[explicit] QChartView:: QChartView ( QWidget * parent = nullptr)

构造图表视图对象采用父级 parent .

[explicit] QChartView:: QChartView ( QChart * chart , QWidget * parent = nullptr)

构造图表视图对象采用父级 parent to display the chart chart . The ownership of the chart is passed to the chart view.

[virtual noexcept] QChartView:: ~QChartView ()

Deletes the chart view object and the associated chart.

QChart *QChartView:: chart () const

返回关联图表的指针。

另请参阅 setChart ().

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

重实现: QGraphicsView::mouseMoveEvent (QMouseEvent *event).

If the rubber band rectangle is displayed in the press event specified by event , the event data is used to update the rubber band geometry. Otherwise, the default QGraphicsView::mouseMoveEvent () implementation is called.

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

重实现: QGraphicsView::mousePressEvent (QMouseEvent *event).

If the left mouse button is pressed and the rubber band is enabled, the event event is accepted and the rubber band is displayed on the screen. This enables the user to select the zoom area.

If some other mouse button is pressed or the rubber band is disabled, the event is passed to QGraphicsView::mousePressEvent ().

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

重实现: QGraphicsView::mouseReleaseEvent (QMouseEvent *event).

If the left mouse button is released and the rubber band is enabled, the event event is accepted and the view is zoomed into the rectangle specified by the rubber band. If releasing the right mouse button triggered the event, the view is zoomed out.

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

重实现: QGraphicsView::resizeEvent (QResizeEvent *event).

Resizes and updates the chart area using the data specified by event .

QChartView::RubberBands QChartView:: rubberBand () const

返回图表视图目前正使用的橡皮筋标志。

另请参阅 setRubberBand ().

void QChartView:: setChart ( QChart * chart )

将当前图表设为 chart . The ownership of the new chart is passed to the chart view and the ownership of the previous chart is released.

To avoid memory leaks, the previous chart must be deleted.

另请参阅 chart ().

void QChartView:: setRubberBand (const QChartView::RubberBands & rubberBand )

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

注意: Rubber band zooming is not supported for polar charts.

另请参阅 rubberBand ().