QChartView Class
QChartView は、チャートを表示できるスタンドアロンのウィジェットです。詳細...
| Header: | #include <QChartView> |
| Inherits: | QGraphicsView |
| Status: | Deprecated |
このクラスは非推奨です。新しいコードでの使用は強く推奨しません。
パブリック型
(since 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 またはQPolarChart クラスを使用する必要があります。
「 QChart 」および「QPolarChart 」も参照してください 。
メンバ型のドキュメント
[since 6.2] enum QChartView::RubberBand
flags QChartView::RubberBands
この列挙型は、長方形のズーム領域に適用できるさまざまなゴムバンド効果の種類を表しています。
| 定数 | 値 | 説明 |
|---|---|---|
QChartView::NoRubberBand | 0x0 | ズーム領域は指定されておらず、したがってズームは有効になっていません。 |
QChartView::VerticalRubberBand | 0x1 | ラバーバンドは、水平方向にチャートのサイズに固定され、垂直方向に引っ張ってズーム領域を指定することができます。 |
QChartView::HorizontalRubberBand | 0x2 | ラバーバンドはチャートの縦方向のサイズに固定されており、横方向に引っ張ってズーム範囲を指定できます。 |
QChartView::RectangleRubberBand | 0x3 | ラバーバンドはクリックされた位置に固定され、垂直方向と水平方向の両方にドラッグしてズーム範囲を指定できます。 |
QChartView::ClickThroughRubberBand | 0x80 | 上記のラバーバンドの選択肢のうち、チャート項目がクリックを受け付ける場合、左クリックをそのチャート項目に受け渡すことを可能にするオプションです。これを選択するには、ラバーバンドの選択モードのいずれかと OR 演算で組み合わせます。 |
この列挙型は Qt 6.2 で導入されました。
RubberBands 型は、QFlags<RubberBand> の typedef です。これは、RubberBand 値の OR 組み合わせを格納します。
メンバ関数のドキュメント
[explicit] QChartView::QChartView(QWidget *parent = nullptr)
親としてparent を持つチャートビューオブジェクトを作成します。
[explicit] QChartView::QChartView(QChart *chart, QWidget *parent = nullptr)
親のparent を持つチャートビューオブジェクトを作成し、チャートchart を表示します。チャートの所有権はチャートビューに渡されます。
[virtual noexcept] QChartView::~QChartView()
チャートビューオブジェクトと、それに関連付けられたチャートを削除します。
QChart *QChartView::chart() const
関連付けられたチャートへのポインタを返します。
setChart()も参照してください 。
[override virtual protected] void QChartView::mouseMoveEvent(QMouseEvent *event)
QGraphicsView::mouseMoveEvent(QMouseEvent *event) を再実装します。
event で指定された押下イベントにおいて、ラバーバンドの矩形が表示されている場合、そのイベントデータを使用してラバーバンドの形状を更新します。そうでない場合は、QGraphicsView::mouseMoveEvent() のデフォルトの実装が呼び出されます。
[override virtual protected] void QChartView::mousePressEvent(QMouseEvent *event)
QGraphicsView::mousePressEvent(QMouseEvent *event) を再実装します。
マウスの左ボタンが押され、ラバーバンドが有効になっている場合、event イベントが受信され、画面上にラバーバンドが表示されます。これにより、ユーザーはズーム範囲を選択できるようになります。
その他のマウスボタンが押された場合、またはラバーバンドが無効になっている場合は、イベントはQGraphicsView::mousePressEvent() に渡されます。
[override virtual protected] void QChartView::mouseReleaseEvent(QMouseEvent *event)
QGraphicsView::mouseReleaseEvent(QMouseEvent *event) を再実装します。
マウスの左ボタンが離され、ラバーバンドが有効になっている場合、event イベントが受信され、ビューはラバーバンドで指定された矩形にズームインされます。マウスの右ボタンの離しによってイベントが発生した場合は、ビューはズームアウトされます。
[override virtual protected] void QChartView::resizeEvent(QResizeEvent *event)
QGraphicsView::resizeEvent(QResizeEvent *event) を再実装します。
event で指定されたデータを使用して、チャート領域のサイズ変更と更新を行います。
QChartView::RubberBands QChartView::rubberBand() const
チャートビューで現在使用されているラバーバンドフラグを返します。
setRubberBand()も参照してください 。
void QChartView::setChart(QChart *chart)
現在のチャートをchart に設定します。新しいチャートの所有権はチャートビューに渡され、以前のチャートの所有権は解放されます。
メモリリークを防ぐため、以前のチャートは削除する必要があります。
chart()も参照してください 。
void QChartView::setRubberBand(const QChartView::RubberBands &rubberBand)
ラバーバンドフラグをrubberBand に設定します。選択されたフラグによって、ズームの動作が決まります。
注: 極座標チャートでは、ラバーバンド ズームはサポートされていません。
「rubberBand()」も参照してください 。
© 2026 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.