简体   繁体   English

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

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

I have Ubuntu 14.04 , I'm working with QT C ++ . 我有Ubuntu 14.04 ,正在使用QT C ++ I will paint two lines ( in QcustomPlot ) Each line has a different color from the other. 我将绘制两行(在QcustomPlot ),每一行具有QcustomPlot不同的颜色。 I will to paint a line Red Then line green, like this My code : 我将画一条红色的线然后画一条绿色的线, 就像我的代码:

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

The problem is that the red line painted on the green How to solve the problem? 问题是红线涂在绿色上怎么解决问题?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM