QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_legend.h
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *
9 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_LEGEND_H
28#define QWT_LEGEND_H
29
30#include "qwt_global.h"
31#include "qwt_abstract_legend.h"
32#include "qwt_legend_data.h"
33
34#include <qvariant.h>
35
36class QScrollBar;
37
54class QWT_EXPORT QwtLegend : public QwtAbstractLegend
55{
56 Q_OBJECT
57
58 public:
59 // Constructor for QwtLegend
60 explicit QwtLegend( QWidget* parent = nullptr );
61 // Destructor
62 virtual ~QwtLegend();
63
64 // Set the maximum number of columns
65 void setMaxColumns( uint numColums );
66 // Return the maximum number of columns
67 uint maxColumns() const;
68
69 // Set the default mode for legend items
70 void setDefaultItemMode( QwtLegendData::Mode );
71 // Return the default mode for legend items
72 QwtLegendData::Mode defaultItemMode() const;
73
74 // Return the contents widget
75 QWidget* contentsWidget();
76 // Return the contents widget (const version)
77 const QWidget* contentsWidget() const;
78
79 // Return the legend widget for a specific item
80 QWidget* legendWidget( const QVariant& ) const;
81 // Return all legend widgets for a specific item
82 QList< QWidget* > legendWidgets( const QVariant& ) const;
83
84 // Return the item info for a specific widget
85 QVariant itemInfo( const QWidget* ) const;
86
87 // Event filter for event handling
88 virtual bool eventFilter( QObject*, QEvent* ) override;
89
90 // Return the size hint
91 virtual QSize sizeHint() const override;
92 // Return the height for a given width
93 virtual int heightForWidth( int w ) const override;
94
95 // Return the horizontal scroll bar
96 QScrollBar* horizontalScrollBar() const;
97 // Return the vertical scroll bar
98 QScrollBar* verticalScrollBar() const;
99
100 // Render the legend to a painter
101 virtual void renderLegend( QPainter*,
102 const QRectF&, bool fillBackground ) const override;
103
104 // Render a single legend item
105 virtual void renderItem( QPainter*,
106 const QWidget*, const QRectF&, bool fillBackground ) const;
107
108 // Check if the legend is empty
109 virtual bool isEmpty() const override;
110 // Return the scroll extent for a specific orientation
111 virtual int scrollExtent( Qt::Orientation ) const override;
112
113 Q_SIGNALS:
130 void clicked( const QVariant& itemInfo, int index );
131
150 void checked( const QVariant& itemInfo, bool on, int index );
151
152 public Q_SLOTS:
153 virtual void updateLegend( const QVariant&,
154 const QList< QwtLegendData >& ) override;
155
156 protected Q_SLOTS:
157 void itemClicked();
158 void itemChecked( bool );
159
160 protected:
161 virtual QWidget* createWidget( const QwtLegendData& ) const;
162 virtual void updateWidget( QWidget*, const QwtLegendData& );
163
164 private:
165 void updateTabOrder();
166
167 class PrivateData;
168 PrivateData* m_data;
169};
170
171#endif
Definition qwt_dyngrid_layout.h:33
图例控件的抽象基类
Definition qwt_abstract_legend.h:57
virtual void renderLegend(QPainter *painter, const QRectF &rect, bool fillBackground) const =0
将图例渲染到给定的矩形中
virtual int scrollExtent(Qt::Orientation) const
返回滚动元素所需的空间范围
Definition qwt_abstract_legend.cpp:70
virtual void updateLegend(const QVariant &itemInfo, const QList< QwtLegendData > &data)=0
更新绘图项的条目
图例条目的属性
Definition qwt_legend_data.h:60
Mode
定义图例条目如何交互的模式
Definition qwt_legend_data.h:71
图例控件
Definition qwt_legend.h:55
void clicked(const QVariant &itemInfo, int index)
当用户点击 Clickable 模式的图例标签时发出的信号
void checked(const QVariant &itemInfo, bool on, int index)
当用户点击 Checkable 模式的图例标签时发出的信号