zoukankan      html  css  js  c++  java
  • QCustomPlot使用经验

    一 QCPItemText文本的添加和删除

    • 添加文本,通过下属代码向QCustomPlot对象中的setCoords设定的位置添加了文本
        QCPItemText *addText =new QCPItemText (textParent);//textParent为QCustomPlot对象
        addText->position->setCoords(pole.dist, updateRangY(textParent,pole.type));
        addText->setFont(QFont(font().family(), 10));    
        addText->setText(QTextCodec::codecForName("gbk")->toUnicode(pole.pole.toLatin1().data()));
        addText->setColor(txtColor);
        textParent->replot();
    • 删除文本,没有想到太好的办法,利用函数addText->setText将文本设置为空,即可实现.
      for(int i=0;i<poleCurves.count();i++)
        {
            qDebug()<<"find del pole"<<i<<pole.dist<<poleCurves.at(i).first.dist<<pole.pole<<poleCurves.at(i).first.pole
                   <<(abs(pole.dist-poleCurves.at(i).first.dist)<0.01)
                  <<(pole.pole==poleCurves.at(i).first.pole);
            if((abs(pole.dist-poleCurves.at(i).first.dist)<0.01)&&poleCurves.at(i).first.pole.contains(pole.pole))
            {
                QPair<PoleInfo,QPair<curveInfo,curveInfo> > tmp=poleCurves.at(i);
                tmp.first.widthText->setText("");
                tmp.first.widthText->position->setCoords(0,0);
                tmp.first.heightText->setText("");
                tmp.first.heightText->position->setCoords(0,0);
                poleCurves.replace(i,tmp);
                pole=poleCurves.at(i).first;
                m_drawWireWidth->graph(poleCurves.at(i).second.first.curveIndex)->setVisible(false);
                m_drawWireHeight->graph(poleCurves.at(i).second.second.curveIndex)->setVisible(false);
                poleCurves.remove(i);
                qDebug()<<"del pole"<<i;
                delFlag=true;
                break;
            }
        }
    

    二 曲线清除

    • 通过隐藏方式
    graph(0)->data().data()->clear();
    
    • 通过清除数据的方式,仅清除了曲线上面数据,曲线的设置被保留
    graph(0)->data().data()->clear()
    

      

  • 相关阅读:
    输入输出那些事
    NYOJ 20
    NYOJ 283
    HDU 1285
    HDU 2639(第K大背包)
    HDU 4288
    对Visual Studio C++ hash_map严谨一点的测试转载
    vc6,vc.net,vc7,vc8,vc9,c,c++,c#的区别与联系
    我在南大的七年刘末鹏
    慎用Visual Studio C++默认的hash_map转载
  • 原文地址:https://www.cnblogs.com/gethope5/p/14956955.html
Copyright © 2011-2022 走看看