// add the text label at the top:
QCPItemText *textLabel =new QCPItemText(customPlot);
customPlot->addItem(textLabel);
textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter);
textLabel->position->setType(QCPItemPosition::ptAxisRectRatio);
textLabel->position->setCoords(0.5, 0); // place position at center/top of axis rect
textLabel->setText("Text Item Demo");
textLabel->setFont(QFont(font().family(), 16)); // make font a bit larger
textLabel->setPen(QPen(Qt::black)); // show black border around text// add the arrow:
QCPItemLine *arrow =new QCPItemLine(customPlot);
customPlot->addItem(arrow);
arrow->start->setParentAnchor(textLabel->bottom);
arrow->end->setCoords(4, 1.6); // point to (4, 1.6) in x-y-plot coordinates
arrow->setHead(QCPLineEnding::esSpikeArrow);
一、基本图形元件 1、QCustomPlot提供文字、箭头、连线、图片等图形元件,以满足用户需要。它们都是继承于QCPAbstractItem这个基类。 继承关系如下: 看官网上的例子:// add the text label at the top:QCPItemText *textLabel = new QCPItemText(customPlot);customPl