Unsolved Real time charts (passing data from c++ to qml)
-
Hi
I have doubts in charts. In my project i display line chart with time axis in xaxis and data will be plotted based on yaxis. In that chart will be updated real time till the process is completed. The time axis will be extend and scroll bar will be displayed to view all the data in chart view. Along that scatter chart are used to mark the two different parameters (symbols)on a particular time. Both charts will be displayed in the view. The data will be updated in c++ to qml . I need some relevant answer or links to clarify my doubts. -
@eswar Check this example:
http://doc.qt.io/qt-5/qtcharts-qmloscilloscope-example.htmlHere they have exposed C++ class as a context property. Check this code especially:
http://doc.qt.io/qt-5/qtcharts-qmloscilloscope-datasource-cpp.html -
What I would do is stick the data in a QStandardItemModel, expose the model and then use a ModelMapper (there are multiple classes depending on the series: http://doc.qt.io/qt-5/qtcharts-qmlmodule.html) to use them in the chart
-
-
@eswar this chunk of code will help you to make your graph be able to scroll in real time
data.pop_back(); data.push_front(QPointF(0, someValue)); for(int i = 0; i < data.size(); i++){ data[i].setX(i); //update X coord to make the grpah scroll }
put it in your function which handles the data transmission from c++ side onto qml side.
-