我创建了一个QPolarChart
,我想隐藏径向刻度线标签,但保留刻度线圈。我只是想摆脱显示“ 0.0”,“ 20.0”等的文本。我试图更改标签格式,但这没有用。
这是我尝试过的最小示例:
#include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QtCharts/QPolarChart>
#include <QtCharts/QValueAxis>
QT_CHARTS_USE_NAMESPACE
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPolarChart *chart = new QPolarChart();
QValueAxis *angularAxis = new QValueAxis();
angularAxis->setTickCount(13);
angularAxis->setLabelFormat("%d");
angularAxis->setRange(0, 361);
chart->addAxis(angularAxis, QPolarChart::PolarOrientationAngular);
QValueAxis *radialAxis = new QValueAxis();
radialAxis->setTickCount(10);
radialAxis->setLabelFormat(""); // <-- what do I have to add here?
radialAxis->setRange(0, 90);
chart->addAxis(radialAxis, QPolarChart::PolarOrientationRadial);
chart->legend()->setVisible(false);
QLineSeries *series = new QLineSeries();
*series << QPointF(0, 0) << QPointF(90, 22.5) << QPointF(180, 45) << QPointF(270, 67.5) << QPointF(360, 90);
chart->addSeries(series);
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
chart->legend()->hide();
QMainWindow window;
window.setCentralWidget(chartView);
window.resize(400, 400);
window.show();
return a.exec();
}