QT QChart坐标轴添加标签、汉字、字母等
QCchart坐标轴添加信息的方法如下:
运用QCategoryAxis类重新编辑坐标轴。
具体实现方法在连接中
https://doc.qt.io/qt-5/qcategoryaxis.html#QCategoryAxis
实现代码
QCategoryAxis *axisX=new QCategoryAxis;
axisX->setMin(0);
axisX->setMax(60);
axisX->setStartValue(0);
//append要按照大小顺序依次添加
axisX->append("0",0);
axisX->append("10",10);
axisX->append("20",20);
axisX->append("30",30);
axisX->append("预测1",35);
axisX->append("预测2",40);
axisX->append("预测3",45);
axisX->append("预测4",50);
axisX->append("60",60);
//下边这一句代码的作用是让刻度线和刻度的label对齐
axisX->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
chart->setAxisX(axisX,series);
实现效果如下图