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. Adding points to a QLineSeries - nothing displayed on chart

Adding points to a QLineSeries - nothing displayed on chart

Scheduled Pinned Locked Moved General and Desktop
qchart qlineser
4 Posts 3 Posters 2.8k Views 1 Watching
  • 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 Offline
    D Offline
    doyal
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      doyal
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        mamsds
        wrote on last edited by
        #3

        Can you explain the solution? I am facing the same issue now...

        JonBJ 1 Reply Last reply
        0
        • M mamsds

          Can you explain the solution? I am facing the same issue now...

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @mamsds
          This thread is a decade old. That OP seems to be claiming that instead of m_temperatureLineSeries = new QLineSeries(); you need m_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.

          1 Reply Last reply
          0

          • Login

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