QChart学习之设置部分图例隐藏
原创
©著作权归作者所有:来自51CTO博客作者小何博客的原创作品,请联系作者获取转载授权,否则将追究法律责任
QChart 设置部分图例隐藏场景介绍
在我们绘制QChart图形中,如果需要绘制折线柱状等多种格式序列时,我们只想柱状图显示图例怎,折线图例隐藏怎么实现呢?
QChart 设置部分图例隐藏解决办法
关键词:
所有序列标记:QList<QLegendMarker *> QLegend::markers(QAbstractSeries *series = Q_NULLPTR) const
枚举值: enum QLegendMarker::LegendMarkerType
The type of the legend marker object.This enum was introduced or modified in Qt 5.8.
Constant |
Value |
Description |
QLegendMarker::LegendMarkerTypeArea |
0 |
A legend marker for an area series. |
QLegendMarker::LegendMarkerTypeBar |
1 |
A legend marker for a bar set. |
QLegendMarker::LegendMarkerTypePie |
2 |
A legend marker for a pie slice. |
QLegendMarker::LegendMarkerTypeXY |
3 |
A legend marker for a line, spline, or scatter series. |
QLegendMarker::LegendMarkerTypeBoxPlot |
4 |
A legend marker for a box plot series. |
QLegendMarker::LegendMarkerTypeCandlestick |
5 |
A legend marker for a candlestick series. |
foreach (QLegendMarker* marker, chart->legend()->markers())
{
if(marker->type() == QLegendMarker::LegendMarkerTypeXY)
{
marker->setVisible(false);
}
}