UbuntuQT中QcustomPlot怎么画两条线?

How do you paint two lines on QcustomPlot in QT in Ubuntu?

我有 Ubuntu 14.04,我正在使用 QT C++。 我将绘制两条线(在 QcustomPlot 中),每条线的颜色都不同。 我会画一条红色线然后画一条绿色线,like this 我的代码:

customPlot->addGraph() ; // color red 
customPlot->addGraph() ; // color green 
customPlot->graph(0)->setPen(QPen(Qt::red));

customPlot->graph(1)->setPen(QPen(Qt::red));
customPlot->graph(1)->setPen(QPen(Qt::green);
customPlot->graphe(0)->adddata(1,1) ;  
customPlot->graphe(0)->adddata(5,1) ;  
customPlot->graphe(1)->adddata(5,1) ; 
customPlot->graphe(1)->adddata(10,1) ;  
customPlot->graphe(0)->adddata(10,1) ; 
customPlot->graphe(0)->adddata(15,1) ;  

问题是红线画在绿线上 如何解决问题?

 QCPItemLine *item ;
item = new QCPItemLine(ui->courbe);
customPlot->addItem(item);

item->setPen(QPen(Qt::red));
item->start->setCoords(1,1);
item->end->setCoords(5,1);

item = new QCPItemLine(ui->courbe);
item->start->setCoords(6,1);
item->end->setCoords(10,1);
customPlot->replot();