pyqt QBarSeries::append
时间: 2023-09-19 14:07:31 浏览: 92
QBarSeries is a class in PyQt that represents a series of bars in a bar chart. The append() method of QBarSeries allows you to add a new bar to the series.
The syntax for the append() method is as follows:
```python
append(QBarSet *set)
```
Here, the parameter set is a QBarSet object that represents the data for the new bar. You can create a QBarSet object by specifying the values for the bar using the constructor:
```python
QBarSet(QString label[, QObject *parent])
```
The label parameter is a string that represents the label for the bar. The parent parameter is optional and specifies the parent object for the QBarSet.
Here is an example of using the append() method to add a bar to a QBarSeries object:
```python
series = QtChart.QBarSeries()
set1 = QtChart.QBarSet("Bar 1")
set1.append(1)
set1.append(2)
set1.append(3)
series.append(set1)
```
This code creates a new QBarSeries object and a new QBarSet object with the label "Bar 1". The append() method is then used to add three values to the QBarSet object. Finally, the append() method is called on the QBarSeries object to add the QBarSet object as a new bar in the bar chart.
阅读全文