Qt QChart QCategoryAxis 坐标轴添加标签、汉字、字母等

QCchart坐标轴添加信息的方法如下:
运用QCategoryAxis类重新编辑坐标轴。
QT QChart坐标轴添加标签、汉字、字母等_第1张图片

 1     QCategoryAxis *axisX=new QCategoryAxis;
 2  
 3     axisX->setMin(0);
 4     axisX->setMax(60);
 5     axisX->setStartValue(0);
 6     //append要按照大小顺序依次添加
 7     axisX->append("0",0);
 8     axisX->append("10",10);
 9     axisX->append("20",20);
10     axisX->append("30",30);
11     axisX->append("预测1",35);
12     axisX->append("预测2",40);
13     axisX->append("预测3",45);
14     axisX->append("预测4",50);
15     axisX->append("60",60);
16     //下边这一句代码的作用是让刻度线和刻度的label对齐
17     axisX->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
18     chart->setAxisX(axisX,series);

实现效果如下图
QT QChart坐标轴添加标签、汉字、字母等_第2张图片

原文地址:https://www.cnblogs.com/ybqjymy/p/14312072.html