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. Exception calling QChart::removeAllSeries
Qt 6.11 is out! See what's new in the release blog

Exception calling QChart::removeAllSeries

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 494 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    Class has a QLineSeries, and QChart

    	QLineSeries scoreSeries;
    	QChart scoreChart;
    

    and a chart view that was set using:

    	chartView->setChart(&scoreChart);
    

    If I have a datapoint I want to add I call:

    scoreSeries.append(x, fScore); scoreChart.removeAllSeries(); scoreChart.addSeries(&scoreSeries);

    thinking that would refresh display of the ChartView.

    The first time I called that it worked, but when I added the second point to the series I get this:

    5a23b8ad-347a-4f8a-bb00-0ac829722025-image.png

    1. I don't think that should happen!
    2. Am I doing this all wrong?
    3. If I have got it wrong what should I do?

    Thanks
    David

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

      Class has a QLineSeries, and QChart

      	QLineSeries scoreSeries;
      	QChart scoreChart;
      

      and a chart view that was set using:

      	chartView->setChart(&scoreChart);
      

      If I have a datapoint I want to add I call:

      scoreSeries.append(x, fScore); scoreChart.removeAllSeries(); scoreChart.addSeries(&scoreSeries);

      thinking that would refresh display of the ChartView.

      The first time I called that it worked, but when I added the second point to the series I get this:

      5a23b8ad-347a-4f8a-bb00-0ac829722025-image.png

      1. I don't think that should happen!
      2. Am I doing this all wrong?
      3. If I have got it wrong what should I do?

      Thanks
      David

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Perdrix said in Exception calling QChart::removeAllSeries:

      scoreChart.addSeries(&scoreSeries);

      My guess would be that QChart expects all QLineSeries (any series) added to it to be on the heap, not stack, and does deletes on them. Try that and everything is then OK?

      PerdrixP 1 Reply Last reply
      1
      • PerdrixP Perdrix has marked this topic as solved on
      • JonBJ JonB

        @Perdrix said in Exception calling QChart::removeAllSeries:

        scoreChart.addSeries(&scoreSeries);

        My guess would be that QChart expects all QLineSeries (any series) added to it to be on the heap, not stack, and does deletes on them. Try that and everything is then OK?

        PerdrixP Offline
        PerdrixP Offline
        Perdrix
        wrote on last edited by
        #3

        @JonB Yes that was part of it plus RemoveAll also deleted the line series, so now I have:

        if (nullptr != scoreSeries)
        	scoreChart.removeSeries(scoreSeries);
        else
        	scoreSeries = new QLineSeries(this);
        
        scoreSeries->append(x, fScore); 		scoreChart.addSeries(scoreSeries);
        scoreChart.createDefaultAxes();
        
        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