Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Adding points to a QLineSeries - nothing displayed on chart

    General and Desktop
    qchart qlineser
    1
    2
    2234
    Loading More Posts
    • 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.
    • D
      doyal last edited by

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

      1 Reply Last reply Reply Quote 0
      • D
        doyal last edited by

        I figured it out. You must instantiate the line series with a reference to the chart. It is not enough to simply add the series to the chart. I believe that is the fix that finally worked.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post