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.

  • Moderators

    @eswar Check this example:

    Here they have exposed C++ class as a context property. Check this code especially:

  • 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: to use them in the chart

  • @p3c0 @VRonin Thanks for your valuable reply

    I go through the qmloscilloscope example already. In that i want extend the x-axes in time and the x axes willbe upadted till the data finished. To add scroll view for the chartview to view the previous data.

  • @eswar this chunk of code will help you to make your graph be able to scroll in real time

        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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.