C++ 如何在Ubuntu的QT中的QcustomPlot上绘制两行?

C++ 如何在Ubuntu的QT中的QcustomPlot上绘制两行?,c++,qt,qcustomplot,C++,Qt,Qcustomplot,我有ubuntu14.04,我正在使用QTC++。 我将画两行(在QcustomPlot中),每一行都有不同的颜色。 我会先画一条红线,然后再画一条绿线, 我的代码: customPlot->addGraph() ; // color red customPlot->addGraph() ; // color green customPlot->graph(0)->setPen(QPen(Qt::red)); customPlot->graph(1)->

我有
ubuntu14.04
,我正在使用
QT
C
++
。 我将画两行(在
QcustomPlot
中),每一行都有不同的颜色。 我会先画一条红线,然后再画一条绿线, 我的代码:

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();