QAbstractBarSeries Class

QAbstractBarSeries 是所有柱状图/条形图系列的基类. 更多...

公有类型

enum LabelsPosition { LabelsCenter, LabelsInsideEnd, LabelsInsideBase, LabelsOutsideEnd }

属性

公有函数

virtual ~QAbstractBarSeries()
bool append(QBarSet *set)
bool append(QList<QBarSet *> sets)
QList<QBarSet *> barSets() const
qreal barWidth() const
void clear()
int count() const
bool insert(int index, QBarSet *set)
bool isLabelsVisible() const
qreal labelsAngle() const
QString labelsFormat() const
QAbstractBarSeries::LabelsPosition labelsPosition() const
bool remove(QBarSet *set)
void setBarWidth(qreal width)
void setLabelsAngle(qreal angle)
void setLabelsFormat(const QString &format)
void setLabelsPosition(QAbstractBarSeries::LabelsPosition position)
void setLabelsVisible(bool visible = true)
bool take(QBarSet *set)

信号

void barsetsAdded(QList<QBarSet *> sets)
void barsetsRemoved(QList<QBarSet *> sets)
void clicked(int index, QBarSet *barset)
void countChanged()
void doubleClicked(int index, QBarSet *barset)
void hovered(bool status, int index, QBarSet *barset)
void labelsAngleChanged(qreal angle)
void labelsFormatChanged(const QString &format)
void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)
void labelsVisibleChanged()
void pressed(int index, QBarSet *barset)
void released(int index, QBarSet *barset)

其他继承的成员

  • 1 个公有槽函数继承自 QObject
  • 1 个公有变量继承自 QObject
  • 10 个静态公有成员继承自 QObject
  • 9 个受保护的函数继承自 QObject
  • 2 个受保护的变量继承自 QObject

详细描述

QAbstractBarSeries 是所有柱状图/条形图系列的基类.

在条形图中, 条形柱被定义为包含一种数据的集合. 条形柱的位置由其类别与数值来决定. 条形柱组合则是属于同一类别的条形柱. 条形柱的显示则是由创建图表的时候决定的.

如果使用 QValueAxis 代替 of QBarCategoryAxis 当做图表的主轴, 那么条形柱别按照索引值来分类.

参见 bar chart example, 学习如何使用 QBarSeries 创建一个简单的柱状图.

参见 QBarSet, QBarSeries, QStackedBarSeries, QPercentBarSeries, QHorizontalBarSeries, QHorizontalStackedBarSeries, and QHorizontalPercentBarSeries.

成员类型

enum QAbstractBarSeries::LabelsPosition

这个枚举值表示的是条形柱标签的位置:

ConstantValueDescription
QAbstractBarSeries::LabelsCenter0中部.
QAbstractBarSeries::LabelsInsideEnd1顶部.
QAbstractBarSeries::LabelsInsideBase2底部.
QAbstractBarSeries::LabelsOutsideEnd3外部.

属性

barWidth : qreal

This property holds the width of the bars of the series.

The unit of width is the unit of the x-axis. The minimum width for bars is zero, and negative values are treated as zero. Setting the width to zero means that the width of the bar on the screen is one pixel regardless of the scale of the x-axis. Bars wider than zero are scaled using the x-axis scale.

Note: When used with QBarSeries, this value specifies the width of a group of bars instead of that of a single bar.

访问函数:

qreal barWidth() const
void setBarWidth(qreal width)

参见 QBarSeries.

count : const int

This property holds the number of bar sets in a bar series.

访问函数:

int count() const

Notifier signal:

void countChanged()

labelsAngle : qreal

This property holds the angle of the value labels in degrees.

访问函数:

qreal labelsAngle() const
void setLabelsAngle(qreal angle)

Notifier signal:

void labelsAngleChanged(qreal angle)

labelsFormat : QString

This property holds the format used for showing labels in a bar series.

QAbstractBarSeries supports the following format tag:

@valueThe value of the bar

For example, the following usage of the format tags would produce labels that show the value followed by the unit (u):


  series->setLabelsFormat("@value u");

By default, the labels show the value of the bar. For the percent bar series, % is added after the value. The labels are shown on the plot area, whereas labels on the edge of the plot area are cut. If the bars are close to each other, the labels may overlap.

访问函数:

QString labelsFormat() const
void setLabelsFormat(const QString &format)

Notifier signal:

void labelsFormatChanged(const QString &format)

参见 labelsVisible and labelsPosition.

labelsPosition : LabelsPosition

This property holds the position of value labels.

访问函数:

QAbstractBarSeries::LabelsPosition labelsPosition() const
void setLabelsPosition(QAbstractBarSeries::LabelsPosition position)

Notifier signal:

void labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)

参见 labelsVisible and labelsFormat.

labelsVisible : bool

This property holds the visibility of the labels in a bar series.

访问函数:

bool isLabelsVisible() const
void setLabelsVisible(bool visible = true)

Notifier signal:

成员函数

[virtual] QAbstractBarSeries::~QAbstractBarSeries()

Removes the abstract bar series and the bar sets owned by it.

bool QAbstractBarSeries::append(QBarSet *set)

Adds a set of bars specified by set to the bar series and takes ownership of it. If the set is null or it already belongs to the series, it will not be appended. Returns true if appending succeeded.

bool QAbstractBarSeries::append(QList<QBarSet *> sets)

Adds a list of bar sets specified by sets to a bar series and takes ownership of the sets. Returns true if all sets were appended successfully. If any of the sets is null or was previously appended to the series, nothing is appended and this function returns false. If any of the sets appears in the list more than once, nothing is appended and this function returns false.

QList<QBarSet *> QAbstractBarSeries::barSets() const

Returns a list of bar sets in a bar series. Keeps the ownership of the bar sets.

qreal QAbstractBarSeries::barWidth() const

Returns the width of the bars of the series.

Note: Getter function for property barWidth.

参见 setBarWidth().

[signal] void QAbstractBarSeries::barsetsAdded(QList<QBarSet *> sets)

This signal is emitted when the bar sets specified by sets are added to the series.

参见 append() and insert().

[signal] void QAbstractBarSeries::barsetsRemoved(QList<QBarSet *> sets)

This signal is emitted when the bar sets specified by sets are removed from the series.

参见 remove().

void QAbstractBarSeries::clear()

Removes all bar sets from the series and permanently deletes them.

[signal] void QAbstractBarSeries::clicked(int index, QBarSet *barset)

This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset.

int QAbstractBarSeries::count() const

Returns the number of bar sets in a bar series.

Note: Getter function for property count.

[signal] void QAbstractBarSeries::countChanged()

This signal is emitted when the number of bar sets is changed, for example by append() or remove().

Note: Notifier signal for property count.

[signal] void QAbstractBarSeries::doubleClicked(int index, QBarSet *barset)

This signal is emitted when the user double-clicks the bar specified by index in the bar set specified by barset.

[signal] void QAbstractBarSeries::hovered(bool status, int index, QBarSet *barset)

This signal is emitted when a mouse is hovered over the bar specified by index in the bar set specified by barset. When the mouse moves over the bar, status turns true, and when the mouse moves away again, it turns false.

bool QAbstractBarSeries::insert(int index, QBarSet *set)

Inserts a bar set specified by set to a series at the position specified by index and takes ownership of the set. If the set is null or already belongs to the series, it will not be appended. Returns true if inserting succeeds.

bool QAbstractBarSeries::isLabelsVisible() const

Returns the visibility of labels.

Note: Getter function for property labelsVisible.

[signal] void QAbstractBarSeries::labelsAngleChanged(qreal angle)

This signal is emitted when the angle of the value labels changes.

Note: Notifier signal for property labelsAngle.

[signal] void QAbstractBarSeries::labelsFormatChanged(const QString &format)

This signal is emitted when the format of data value labels changes.

Note: Notifier signal for property labelsFormat.

[signal] void QAbstractBarSeries::labelsPositionChanged(QAbstractBarSeries::LabelsPosition position)

This signal is emitted when the position of value labels changes.

Note: Notifier signal for property labelsPosition.

[signal] void QAbstractBarSeries::labelsVisibleChanged()

This signal is emitted when the labels' visibility changes.

Note: Notifier signal for property labelsVisible.

参见 isLabelsVisible() and setLabelsVisible().

[signal] void QAbstractBarSeries::pressed(int index, QBarSet *barset)

This signal is emitted when the user clicks the bar specified by index in the bar set specified by barset and holds down the mouse button.

[signal] void QAbstractBarSeries::released(int index, QBarSet *barset)

This signal is emitted when the user releases the mouse press on the bar specified by index in the bar set specified by barset.

bool QAbstractBarSeries::remove(QBarSet *set)

Removes the bar set specified by set from the series and permanently deletes it if the removal succeeds. Returns true if the set was removed.

void QAbstractBarSeries::setBarWidth(qreal width)

Sets the width of the bars of the series to width.

Note: Setter function for property barWidth.

参见 barWidth().

void QAbstractBarSeries::setLabelsVisible(bool visible = true)

Sets the visibility of labels in a bar series to visible.

Note: Setter function for property labelsVisible.

参见 isLabelsVisible().

bool QAbstractBarSeries::take(QBarSet *set)

Takes a single set from the series. Does not delete the bar set object.

Note: The series remains the barset's parent object. You must set the parent object to take full ownership.

Returns true if the take operation succeeds.