Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Decimals in labels on an axis of a QChart[View]

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 4.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ibkv
    wrote on last edited by ibkv
    #1

    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?

    1 Reply Last reply
    0
    • YashpalY Offline
      YashpalY Offline
      Yashpal
      wrote on last edited by
      #2

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

        QChartView *chartView = new QChartView;
        QLineSeries *series = new QLineSeries;
        // ...
        chartView->chart()->addSeries(series);
      
        QValueAxis *axisX = new QValueAxis;
        axisX->setRange(10, 20.5);
        axisX->setTickCount(10);
        axisX->setLabelFormat("%.2f");
        chartView->chart()->setAxisX(axisX, series);
      
      
      1 Reply Last reply
      5

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved