QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
| Public 槽 | 信号 | Public 成员函数 | Protected 槽 | Protected 成员函数 | 所有成员列表
QwtLegend类 参考

The legend widget 更多...

#include <qwt_legend.h>

类 QwtLegend 继承关系图:
QwtAbstractLegend

class  PrivateData
 

Public 槽

virtual void updateLegend (const QVariant &, const QList< QwtLegendData > &) override
 Update the entries for an item
 
- Public 槽 继承自 QwtAbstractLegend
virtual void updateLegend (const QVariant &itemInfo, const QList< QwtLegendData > &data)=0
 

信号

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
 

Public 成员函数

 QwtLegend (QWidget *parent=nullptr)
 Constructor for QwtLegend
 
void setMaxColumns (uint numColums)
 Set the maximum number of entries in a row
 
uint maxColumns () const
 Return the maximum number of entries in a row
 
void setDefaultItemMode (QwtLegendData::Mode)
 Set the default mode for legend labels
 
QwtLegendData::Mode defaultItemMode () const
 Return the default item mode
 
QWidget * contentsWidget ()
 Return the contents widget
 
const QWidget * contentsWidget () const
 Return the contents widget (const version)
 
QWidget * legendWidget (const QVariant &) const
 Return first widget in the list of widgets associated to an item
 
QList< QWidget * > legendWidgets (const QVariant &) const
 Return list of widgets associated to an item
 
QVariant itemInfo (const QWidget *) const
 Find the item that is associated to a widget
 
virtual bool eventFilter (QObject *, QEvent *) override
 Handle QEvent::ChildRemoved and QEvent::LayoutRequest events
 
virtual QSize sizeHint () const override
 Return a size hint
 
virtual int heightForWidth (int w) const override
 Return the preferred height for a given width
 
QScrollBar * horizontalScrollBar () const
 Return the horizontal scrollbar
 
QScrollBar * verticalScrollBar () const
 Return the vertical scrollbar
 
virtual void renderLegend (QPainter *, const QRectF &, bool fillBackground) const override
 Render the legend into a given rectangle
 
virtual void renderItem (QPainter *, const QWidget *, const QRectF &, bool fillBackground) const
 Render a legend entry into a given rectangle
 
virtual bool isEmpty () const override
 Check if the legend is empty
 
virtual int scrollExtent (Qt::Orientation) const override
 Return the extent that is needed for the scrollbars
 
- Public 成员函数 继承自 QwtAbstractLegend
 QwtAbstractLegend (QWidget *parent=nullptr)
 Constructor for QwtAbstractLegend
 
 ~QwtAbstractLegend () override
 Destructor for QwtAbstractLegend
 

Protected 槽

void itemClicked ()
 Called internally when the legend has been clicked on
 
void itemChecked (bool)
 Called internally when the legend has been checked
 

Protected 成员函数

virtual QWidget * createWidget (const QwtLegendData &) const
 Create a widget to be inserted into the legend
 
virtual void updateWidget (QWidget *, const QwtLegendData &)
 Update the widget
 

详细描述

The legend widget

The QwtLegend widget is a tabular arrangement of legend items. Legend items might be any type of widget, but in general they will be a QwtLegendLabel.

参见
QwtLegendLabel, QwtPlotItem, QwtPlot

构造及析构函数说明

◆ QwtLegend()

QwtLegend::QwtLegend ( QWidget *  parent = nullptr)
explicit

Constructor for QwtLegend

参数
parentParent widget

Destructor

成员函数说明

◆ checked

void QwtLegend::checked ( const QVariant &  itemInfo,
bool  on,
int  index 
)
signal

Signal emitted when the user clicks on a legend label in Checkable mode

参数
itemInfoInfo for the item of the selected legend label
onTrue when the legend label is checked
indexIndex of the legend label in the list of widgets associated with the plot item
注解
Clicks are disabled as default
参见
setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()

◆ clicked

void QwtLegend::clicked ( const QVariant &  itemInfo,
int  index 
)
signal

Signal emitted when the user clicks on a legend label in Clickable mode

参数
itemInfoInfo for the item of the selected legend item
indexIndex of the legend label in the list of widgets associated with the plot item
注解
Clicks are disabled as default
参见
setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()

◆ contentsWidget() [1/2]

QWidget * QwtLegend::contentsWidget ( )

Return the contents widget

The contents widget is the only child of the viewport of the internal QScrollArea and the parent widget of all legend items.

返回
Container widget of the legend items

◆ contentsWidget() [2/2]

const QWidget * QwtLegend::contentsWidget ( ) const

Return the contents widget (const version)

The contents widget is the only child of the viewport of the internal QScrollArea and the parent widget of all legend items.

返回
Container widget of the legend items

◆ createWidget()

QWidget * QwtLegend::createWidget ( const QwtLegendData legendData) const
protectedvirtual

Create a widget to be inserted into the legend

The default implementation returns a QwtLegendLabel.

参数
legendDataAttributes of the legend entry
返回
Widget representing data on the legend
注解
updateWidget() will called soon after createWidget() with the same attributes.
参见
updateWidget()

◆ defaultItemMode()

QwtLegendData::Mode QwtLegend::defaultItemMode ( ) const

Return the default item mode

返回
Default item mode
参见
setDefaultItemMode()

◆ eventFilter()

bool QwtLegend::eventFilter ( QObject *  object,
QEvent *  event 
)
overridevirtual

Handle QEvent::ChildRemoved and QEvent::LayoutRequest events

Handle QEvent::ChildRemoved and QEvent::LayoutRequest events for the contentsWidget().

参数
objectObject to be filtered
eventEvent
返回
Forwarded to QwtAbstractLegend::eventFilter()

◆ heightForWidth()

int QwtLegend::heightForWidth ( int  width) const
overridevirtual

Return the preferred height for a given width

参数
widthWidth
返回
Preferred height
参见
sizeHint()

◆ horizontalScrollBar()

QScrollBar * QwtLegend::horizontalScrollBar ( ) const

Return the horizontal scrollbar

返回
Horizontal scrollbar
参见
verticalScrollBar()

◆ isEmpty()

bool QwtLegend::isEmpty ( ) const
overridevirtual

Check if the legend is empty

返回
True, when no item is inserted

实现了 QwtAbstractLegend.

◆ itemChecked

void QwtLegend::itemChecked ( bool  on)
protectedslot

Called internally when the legend has been checked

Emits a checked() signal.

参见
checked(), itemClicked()

◆ itemClicked

void QwtLegend::itemClicked ( )
protectedslot

Called internally when the legend has been clicked on

Emits a clicked() signal.

参见
clicked(), itemChecked()

◆ itemInfo()

QVariant QwtLegend::itemInfo ( const QWidget *  widget) const

Find the item that is associated to a widget

参数
widgetWidget on the legend
返回
Associated item info
参见
legendWidget()

◆ legendWidget()

QWidget * QwtLegend::legendWidget ( const QVariant &  itemInfo) const

Return first widget in the list of widgets associated to an item

参数
itemInfoInfo about an item
返回
First widget in the list of widgets associated to an item
参见
itemInfo(), QwtPlot::itemToInfo()
注解
Almost all types of items have only one widget

◆ legendWidgets()

QList< QWidget * > QwtLegend::legendWidgets ( const QVariant &  itemInfo) const

Return list of widgets associated to an item

参数
itemInfoInfo about an item
返回
List of widgets associated to an item
参见
legendWidget(), itemInfo(), QwtPlot::itemToInfo()

◆ maxColumns()

uint QwtLegend::maxColumns ( ) const

Return the maximum number of entries in a row

返回
Maximum number of entries in a row
参见
setMaxColumns(), QwtDynGridLayout::maxColumns()

◆ renderItem()

void QwtLegend::renderItem ( QPainter *  painter,
const QWidget *  widget,
const QRectF &  rect,
bool  fillBackground 
) const
virtual

Render a legend entry into a given rectangle

参数
painterPainter
widgetWidget representing a legend entry
rectBounding rectangle
fillBackgroundWhen true, fill rect with the widget background
注解
When widget is not derived from QwtLegendLabel renderItem does nothing beside the background

◆ renderLegend()

void QwtLegend::renderLegend ( QPainter *  painter,
const QRectF &  rect,
bool  fillBackground 
) const
overridevirtual

Render the legend into a given rectangle

参数
painterPainter
rectBounding rectangle
fillBackgroundWhen true, fill rect with the widget background
参见
renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself

实现了 QwtAbstractLegend.

◆ scrollExtent()

int QwtLegend::scrollExtent ( Qt::Orientation  orientation) const
overridevirtual

Return the extent that is needed for the scrollbars

参数
orientationOrientation
返回
The width of the vertical scrollbar for Qt::Horizontal and v.v.

重载 QwtAbstractLegend .

◆ setDefaultItemMode()

void QwtLegend::setDefaultItemMode ( QwtLegendData::Mode  mode)

Set the default mode for legend labels

Legend labels will be constructed according to the attributes in a QwtLegendData object. When it doesn't contain a value for the QwtLegendData::ModeRole the label will be initialized with the default mode of the legend.

参数
modeDefault item mode
参见
itemMode(), QwtLegendData::value(), QwtPlotItem::legendData()
注解
Changing the mode doesn't have any effect on existing labels.

◆ setMaxColumns()

void QwtLegend::setMaxColumns ( uint  numColums)

Set the maximum number of entries in a row

F.e when the maximum is set to 1 all items are aligned vertically. 0 means unlimited

参数
numColumsMaximum number of entries in a row
参见
maxColumns(), QwtDynGridLayout::setMaxColumns()

◆ sizeHint()

QSize QwtLegend::sizeHint ( ) const
overridevirtual

Return a size hint

返回
Size hint
参见
heightForWidth()

◆ updateLegend

void QwtLegend::updateLegend ( const QVariant &  itemInfo,
const QList< QwtLegendData > &  legendData 
)
overridevirtualslot

Update the entries for an item

参数
itemInfoInfo for an item
legendDataList of legend entry attributes for the item
参见
updateWidget(), createWidget()

◆ updateWidget()

void QwtLegend::updateWidget ( QWidget *  widget,
const QwtLegendData legendData 
)
protectedvirtual

Update the widget

参数
widgetUsually a QwtLegendLabel
legendDataAttributes to be displayed
参见
createWidget()
注解
When widget is no QwtLegendLabel updateWidget() does nothing.

◆ verticalScrollBar()

QScrollBar * QwtLegend::verticalScrollBar ( ) const

Return the vertical scrollbar

返回
Vertical scrollbar
参见
horizontalScrollBar()

该类的文档由以下文件生成: