QCustomPlot::addGraph
时间: 2024-01-11 09:03:03 浏览: 74
QCustomPlot
QCustomPlot::addGraph adds a new graph to the plot and returns a pointer to the added graph. The function takes no arguments and the returned pointer can be used to modify properties of the graph, such as its color, line style, data, etc.
Example usage:
```cpp
QCustomPlot *customPlot = new QCustomPlot();
QCPGraph *graph = customPlot->addGraph();
graph->setData(x, y); // set data for the graph
graph->setLineStyle(QCPGraph::lsLine); // set line style to line
graph->setPen(QPen(Qt::red)); // set pen color to red
```
In this example, a new graph is added to the custom plot, and its data is set using the setData function. The line style is set to a solid line, and the pen color is set to red. The returned pointer to the graph is stored in the variable `graph` which can be used later to modify the graph's properties.
阅读全文