QT QcustomPlot的使用(二)

在QcustomPlot中,给横纵坐标添加箭头的方法

//在末尾添加箭头   
customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow); customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);

怎么给图画虚线的方法

//设置虚线
QPen linesPen(Qt::red,1,Qt::DashLine); line = new QCPItemStraightLine(customPlot); line->setPen(linesPen); line->setClipToAxisRect(true); line->point1->setCoords(0,0); line->point2->setCoords(0,0); line->point1->setCoords(customPlot->xAxis->range().lower,0.2); line->point2->setCoords(customPlot->xAxis->range().upper,0.2);

文本框的设置

//创建文本对象
QCPItemText *text = new QCPItemText(customPlot);
//设置文本坐标解析方式 text
->position->setType(QCPItemPosition::ptAxisRectRatio);
//设置位置在矩形区域的位置 text
->setPositionAlignment(Qt::AlignLeft | Qt::AlignBottom);
//设置位置 text
->position->setCoords(0.1,0.90);
//设置文本内容 text
->setText("你好"); text->setTextAlignment(Qt::AlignLeft);
//设置颜色 text
->setColor(QColor(Qt::red));
//设置页边距 text
->setPadding(QMargins(1,1,1,1));

步长的设置

//创建对象
QSharedPointer<QCPAxisTickerFixed> intTicker( new QCPAxisTickerFixed );
//设置步长精度 intTicker
->setTickStep(0.1);
//设置y轴步长 customPlot
->yAxis->setTicker(intTicker);

猜你喜欢

转载自www.cnblogs.com/caozewen/p/11316543.html
今日推荐