Qt QChartView class

QChartView是一个可以显示图表的独立窗口部件。

头文件:#include <QChartView>

继承:QGraphicsView

公开类型:
enum 
RubberBand { NoRubberBand, VerticalRubberBand, HorizontalRubberBand, RectangleRubberBand }

该枚举描述了可以应用于矩形缩放区域的不同类型的橡皮筋效果。

常量描述

QChartView::NoRubberBand

0x0

未指定缩放区域,因此无法启用缩放。

QChartView::VerticalRubberBand

0x1

橡皮筋水平锁定在图表的大小,可以垂直拉动以指定缩放区域。

QChartView::HorizontalRubberBand

0x2

橡皮筋会垂直锁定到图表大小,并且可以水平拉动以指定缩放区域。

QChartView::RectangleRubberBand

0x3橡皮筋固定在被点击的位置,可以垂直和水平拉动。

RubberBands类型是QFlags <RubberBand>的typedef。 它存储RubberBand值的OR组合。

公有函数:

QChartView(QChart *chart, QWidget *parent = nullptr)

QChartView(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
相关非会员:


typedef QObjectList
QList<T> qFindChildren(const QObject *obj, const QRegExp &regExp)
T qobject_cast(QObject *object)
T qobject_cast(const QObject *object)
宏:


QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
QWIDGETSIZE_MAX
Q_CLASSINFO(Name, Value)
Q_DISABLE_COPY(Class)
Q_DISABLE_COPY_MOVE(Class)
Q_DISABLE_MOVE(Class)
Q_EMIT
Q_ENUM(...)
Q_ENUM_NS(...)
Q_FLAG(...)
Q_FLAG_NS(...)
Q_GADGET
Q_INTERFACES(...)
Q_INVOKABLE
Q_NAMESPACE
Q_OBJECT
Q_PROPERTY(...)
Q_REVISION
Q_SET_OBJECT_NAME(Object)
Q_SIGNAL
Q_SIGNALS
Q_SLOT
Q_SLOTS
详细描述:

图表视图不需要QGraphicsScene对象即可工作。 要在现有QGraphicsScene中显示图表,应改用QChart或QPolarChart类。

成员函数说明:

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

Constructs a chart view object with the parent parent to display the chart chart. The ownership of the chart is passed to the chart view.

使用父级构造一个图表视图对象以显示图表。 图表的所有权被传递到图表视图。

QChartView::QChartView(QWidget *parent = nullptr)

Constructs a chart view object with the parent parent.

构造一个chartview实例使用父类

[virtual] QChartView::~QChartView()

Deletes the chart view object and the associated chart.

删除一个chartview以及相关的图表

QChart *QChartView::chart() const

Returns the pointer to the associated chart.

See also setChart().

返回相关的图表指针

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

Reimplements: 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.

如果橡皮筋矩形显示在事件指定的新闻事件中,则事件数据将用于更新橡皮筋的几何形状。 否则,将调用默认的QGraphicsView :: mouseMoveEvent()实现。

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

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

如果按下鼠标左键并启用了橡皮筋,则接受事件事件,并且橡皮筋显示在屏幕上。 这使用户能够选择缩放区域。

如果按下了其他鼠标按钮或禁用了橡皮筋,则事件将传递到QGraphicsView :: mousePressEvent()。

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

Reimplements: 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)

Reimplements: QGraphicsView::resizeEvent(QResizeEvent *event).

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

使用事件指定的数据调整和更新图表区域。

QChartView::RubberBands QChartView::rubberBand() const

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

See also setRubberBand().

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

void QChartView::setChart(QChart *chart)

Sets the current chart to 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.

将当前图表设置为图表。 新图表的所有权将传递到图表视图,并释放前一个图表的所有权。

为避免内存泄漏,必须删除以前的图表。

See also chart().

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

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

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

将橡皮筋标志设置为rubberBand。 所选标志确定执行缩放的方式。

注意:极坐标图不支持橡皮筋缩放。

See also rubberBand().

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值