'QPolarChart hide radial tick labels

I have created a QPolarChart and I want to hide the radial tick labels but leave the tick circles. I simply want to get rid of the text which shows "0.0", "20.0" and so on. I tried to change the label format but this did not work.

Here is a minimal example of what I tried:

#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();
}

This is how the result looks like. I want to get rid of the radial axis labels ("0.0", "10.0" ... "90.0") example



Solution 1:[1]

The trick is to set as labelFormat to " " or an invalid format like "@":

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

enter image description here

Solution 2:[2]

radialAxis->setLabelsVisible(false);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eyllanesc
Solution 2 Suraj Rao