QPolarChart 隐藏径向刻度标签

QPolarChart hide radial tick labels

我创建了一个 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();
}

结果是这样的。 我想摆脱径向轴标签(“0.0”,“10.0”...“90.0”)

诀窍是将 labelFormat 设置为 " " 或无效格式,如 "@":

radialAxis->setLabelFormat(" ");
# or radialAxis->setLabelFormat("@");

radialAxis->setLabelsVisible(false);