Adding points to a QLineSeries - nothing displayed on chart
-
I'm working in widget space. I create a chart, it shows up with default axes on my GUI. I also create a QLineSeries and assign it to the chart. Later, as data rolls in, I add points to the QLineSeries. But nothing shows up. No line is created. Here is source for instantiating, followed by slot handler source for updating. You can see i rely on QT built in promotion to convert data to qreal.
void SxDiagTECVerificationView::mCreateTemperatureChart()
{
QHBoxLayout* chartLayout = new QHBoxLayout(m_testUI.grpTEC_Chart);
m_temperatureChart = new QChart();
m_temperatureChart->setAnimationOptions(QChart::AllAnimations);
m_temperatureChart->legend()->hide();
m_temperatureChartView = new QChartView(m_temperatureChart);
chartLayout->addWidget(m_temperatureChartView);
m_temperatureLineSeries = new QLineSeries();
m_temperatureChart->addSeries(m_temperatureLineSeries);
m_temperatureChart->createDefaultAxes();
}void SxDiagTECVerificationView::on_timeAndTemperatureUpdate(float temperature, unsigned int elapsedTimeMsec)
{
m_temperatureLineSeries->append(elapsedTimeMsec, temperature);
m_temperatureLineSeries->show();
QApplication::processEvents(QEventLoop::AllEvents);
} -
@mamsds
This thread is a decade old. That OP seems to be claiming that instead ofm_temperatureLineSeries = new QLineSeries();
you needm_temperatureLineSeries = new QLineSeries(m_temperatureChart );
. However I do not believe that is true/will make any difference:m_temperatureChart->addSeries(m_temperatureLineSeries);
line does that anyway.I suggest you open your own thread if you have a problem. You will need a minimal, standalone example program which illustrates the issue.