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. Real time charts (passing data from c++ to qml)
Qt 6.11 is out! See what's new in the release blog

Real time charts (passing data from c++ to qml)

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 7.1k Views 2 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.
  • E Offline
    E Offline
    eswar
    wrote on last edited by eswar
    #1

    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.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @eswar Check this example:
      http://doc.qt.io/qt-5/qtcharts-qmloscilloscope-example.html

      Here they have exposed C++ class as a context property. Check this code especially:
      http://doc.qt.io/qt-5/qtcharts-qmloscilloscope-datasource-cpp.html

      157

      1 Reply Last reply
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        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

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2
        • E Offline
          E Offline
          eswar
          wrote on last edited by
          #4

          @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.

          MikhailGM 1 Reply Last reply
          0
          • E eswar

            @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.

            MikhailGM Offline
            MikhailGM Offline
            MikhailG
            wrote on last edited by MikhailG
            #5

            @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.

            1 Reply Last reply
            1
            • A Offline
              A Offline
              asterixxx
              wrote on last edited by
              #6

              https://www.youtube.com/watch?v=lXXUxy5Opds

              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