Important: Please read the Qt Code of Conduct -

Spline Chart

  • 52551c4f-52dd-42cf-9f74-2e1b5cf74e1c-image.png

    QChart* QTemperatureChart::createSplineChart()
    	m_pChart = new QChart();
    	m_pChart->setTitle("Spline chart");
    	// The lower series initialized to zero values
    	QString name("Series ");
    	int nameIndex = 0;
    	m_pSplineSeries = new QSplineSeries(m_pChart);
    	m_pChart->addAxis(m_valueAxisX = new QValueAxis(), Qt::AlignBottom);
    	m_pChart->addAxis(m_valueAxisY = new QValueAxis(), Qt::AlignLeft);
    	m_valueAxisX->setRange(0, 6);
    	m_valueAxisY->setRange(0, 100);
    	//m_pChart->axes(Qt::Vertical).first()->setRange(0, 10);
    	return m_pChart;
    void QTemperatureChart::UpdateChart(QPointF point)
    	int randomx = QRandomGenerator::global()->bounded(0, 100);
    	int randomy = QRandomGenerator::global()->bounded(0, 100);
    	m_pSplineSeries->append(m_pSplineSeries->count(), randomy);
    	m_pChart->scroll(10, 0);


    I want to increase the x-axis by one on the chart, but it's increasing by 0.1.
    And I want to fix the graph in the middle, so I think I can use Scroll.
    But it doesn't work.

Log in to reply