1 效果图
2 代码
is2Label = QString("add title layout element");
// add title layout element:
ui->customplot->plotLayout()->insertRow(0);
ui->customplot->plotLayout()->addElement(0, 0, new QCPTextElement(ui->customplot, xAxis2Label, QFont("sans", 10, QFont::Bold)));
QCPTextElement *mQCPTextElement = new QCPTextElement(ui->customplot, " 右",QFont("sans", 9, QFont::Normal));
mQCPTextElement->setTextFlags(Qt::AlignLeft);
int c = ui->customplot->plotLayout()->elementCount();
ui->customplot->plotLayout()->addElement(c, 0,mQCPTextElement );