Decimals in labels on an axis of a QChart[View]

  • I have a QLineSeries/QChart displayed in a QChartView. Even though the points I've added are whole numbers, the display graph shows decimals point along the X/Y axes. How do I turn off the decimals points, i.e., specify 0 decimals?

  • You can use format specifiers, have a look at the following example from Qt documentation.

      QChartView *chartView = new QChartView;
      QLineSeries *series = new QLineSeries;
      // ...
      QValueAxis *axisX = new QValueAxis;
      axisX->setRange(10, 20.5);
      chartView->chart()->setAxisX(axisX, series);

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.