【问题标题】:How do you paint two lines on QcustomPlot in QT in Ubuntu?你如何在 Ubuntu 的 QT 中的 QcustomPlot 上绘制两条线?
【发布时间】:2016-07-13 01:38:54
【问题描述】:

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

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

【问题讨论】:

    标签: c++ qt qcustomplot


    【解决方案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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-02
      相关资源
      最近更新 更多