QWT API (中文) 7.3.0
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
46class QWT_EXPORT QwtLegend : public QwtAbstractLegend
47{
48 Q_OBJECT
49
50public:
51 // Constructor for QwtLegend
52 explicit QwtLegend(QWidget* parent = nullptr);
53 // Destructor
54 ~QwtLegend() override;
55
56 // Set the maximum number of columns
57 void setMaxColumns(uint numColums);
58 // Return the maximum number of columns
59 uint maxColumns() const;
60
61 // Set the default mode for legend items
62 void setDefaultItemMode(QwtLegendData::Mode);
63 // Return the default mode for legend items
64 QwtLegendData::Mode defaultItemMode() const;
65
66 // Return the contents widget
67 QWidget* contentsWidget();
68 // Return the contents widget (const version)
69 const QWidget* contentsWidget() const;
70
71 // Return the legend widget for a specific item
72 QWidget* legendWidget(const QVariant&) const;
73 // Return all legend widgets for a specific item
74 QList< QWidget* > legendWidgets(const QVariant&) const;
75
76 // Return the item info for a specific widget
77 QVariant itemInfo(const QWidget*) const;
78
79 // Event filter for event handling
80 virtual bool eventFilter(QObject*, QEvent*) override;
81
82 // Return the size hint
83 virtual QSize sizeHint() const override;
84 // Return the height for a given width
85 virtual int heightForWidth(int w) const override;
86
87 // Return the horizontal scroll bar
88 QScrollBar* horizontalScrollBar() const;
89 // Return the vertical scroll bar
90 QScrollBar* verticalScrollBar() const;
91
92 // Render the legend to a painter
93 virtual void renderLegend(QPainter*, const QRectF&, bool fillBackground) const override;
94
95 // Render a single legend item
96 virtual void renderItem(QPainter*, const QWidget*, const QRectF&, bool fillBackground) const;
97
98 // Check if the legend is empty
99 virtual bool isEmpty() const override;
100 // Return the scroll extent for a specific orientation
101 virtual int scrollExtent(Qt::Orientation) const override;
102
103Q_SIGNALS:
111 void clicked(const QVariant& itemInfo, int index);
112
121 void checked(const QVariant& itemInfo, bool on, int index);
122
123public Q_SLOTS:
124 virtual void updateLegend(const QVariant&, const QList< QwtLegendData >&) override;
125
126protected Q_SLOTS:
127 void itemClicked();
128 void itemChecked(bool);
129
130protected:
131 virtual QWidget* createWidget(const QwtLegendData&) const;
132 virtual void updateWidget(QWidget*, const QwtLegendData&);
133
134private:
135 void updateTabOrder();
136
137 QWT_DECLARE_PRIVATE(QwtLegend)
138};
139
140#endif
Definition qwt_raster_data.h:38
Abstract base class for legend widgets
Definition qwt_abstract_legend.h:47
virtual int scrollExtent(Qt::Orientation) const
Return the extent needed for scroll elements
Definition qwt_abstract_legend.cpp:51
Attributes of an entry on a legend
Definition qwt_legend_data.h:49
Mode
Mode defining how a legend entry interacts
Definition qwt_legend_data.h:55
The legend widget
Definition qwt_legend.h:47
void clicked(const QVariant &itemInfo, int index)
Signal emitted when the user clicks on a legend label in Clickable mode
void checked(const QVariant &itemInfo, bool on, int index)
Signal emitted when the user clicks on a legend label in Checkable mode