如何动态更改QLineSeries数据?

时间:2019-06-27 13:54:51

标签: c++ qt

我正在尝试更改QLinet实例变量中的数据以实时绘制QChart。我希望我的QLineSeries接受这些新数据并不仅实时显示它,还将所有要存储在streamList中的点都放在前面。

Class { 

  lineSeries = new QLineSeries();
  Chart * chart = new Chart();

    // chart->legend()->hide();
    chart->addSeries(lineSeries);
    chart->createDefaultAxes();

    this->setChart(chart);

    QDateTimeAxis *axisX = new QDateTimeAxis;
    axisX->setFormat("m:ss");
    axisX->setTickCount(10);
    axisX->setTitleText("Time m:s");
    this->chart()->setAxisX(axisX, lineSeries);

    return(chart);

}


void RecordGraph::changeStream(int selectedStream) {
   lineSeries =  streamList[selectedStream]  
//this is where I want to set the data displayed aka lineSeries

}

这是我的课程,我在其中记录我希望能够动态绘制的“流”的数据。运行正常。

void RecordWidgetGraph::recordMultipleStreams(StreamObject object){ //Will gather data for lineSeries for multiple streams

    if (firstRound){
        for(int i = 0; i < object.streams.count(); i++){

            quint64 hashKey = object.streams.keys().at(i);

            QLineSeries *newLineSeries = new QLineSeries();
            this->streamList.append(newLineSeries);
            streamList[i]->append( object.streams[hashKey].currentTime, object.streams[hashKey].currentBitrate);

        }

        this->firstRound = false;
    } else {
        for(int i = 0; i < object.streams.count(); i++){
            quint64 hashKey = object.streams.keys().at(i);
            streamList[i]->append( object.streams[hashKey].currentTime, object.streams[hashKey].currentBitrate);
        }
    }

}

如何将存储在streamList中的对象中的数据传输到lineSeries? 在调用changeStream()之前,将正确显示Lineseries。

0 个答案:

没有答案