Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QT QML realtime chart
QtWS25 Last Chance

QT QML realtime chart

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqml c++qml bindingchartviewchart
5 Posts 3 Posters 1.2k Views
  • 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.
  • V Offline
    V Offline
    vicky_mac
    wrote on last edited by vicky_mac
    #1

    Hi this my code which is working file. It takes data from C++ "valfromCpluplus" and plot on the chart.

    My concern is whether this approach is fine or not. Because my application may be running for days and increment of "yval" and "scrolleft()" is bothering me.

    Because after sometime yval and scrolleft will reach their max limit and then there may be unknown situations in the application.

    I want to maintain the history of around 200 updates on chart and new entry will remove the oldest and the hart will be kept on scrolling with new values.

    import QtQuick 2.0
    import QtCharts 2.0
    
    Item {
        anchors.fill: parent
    
        property int valfromCplusplus: 0
        propery LineSeries series: NULL 
        property int yval:0
       Text{
           id:txt
          text: valfromCplusplus
    
         onTextChanged{
                        yval++;
                        chart.series(0).append(valfromCplusplus,yval);
                       if(yval >200)
                        {
                          chart.series(0).remove();
                          chart.scrolleft(1);
                        }
               }
    }
    
    
        ChartView {
            title: chart
            anchors.fill: parent
            legend.visible: false
            antialiasing: true
    
            ValueAxis {
                id: axisX
    
            }
    
            ValueAxis {
                id: axisY
    
            }
    
    component.onComplete{
    series = chart.createSeries(ChartView.SeriesLineSeries, "Line", axisX, axisY);
    }
     }
    

    Please ignore if there is any mistake in the code because i have running code similar to this. Please consider it as a pseudo code(algo) and suggest some suitable solution how i can achieve the intended goal without uncertainties.

    @SGaist @jsulm

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bob64
      wrote on last edited by
      #2

      I think this looks OK in principle. I have a dynamically updating chart in my application and I update the x-axis range rather than using scroll left. I don't know is better or worse for any reason.

      V 1 Reply Last reply
      0
      • B Bob64

        I think this looks OK in principle. I have a dynamically updating chart in my application and I update the x-axis range rather than using scroll left. I don't know is better or worse for any reason.

        V Offline
        V Offline
        vicky_mac
        wrote on last edited by
        #3

        @Bob64 I am worried about yval and scrolleft() values.If i keep it on for days , yval will teacher to max value of int and may rollover similar with scrolleft . Will that not be a problem?

        J.HilkJ 1 Reply Last reply
        0
        • V vicky_mac

          @Bob64 I am worried about yval and scrolleft() values.If i keep it on for days , yval will teacher to max value of int and may rollover similar with scrolleft . Will that not be a problem?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @vicky_mac the highest number int can become in qml is 2^31 - 1 aka 2147483647, if you increment your int every second, you will have an integer overflow after roughly 68 years.

          so I think you will be fine.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          V 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @vicky_mac the highest number int can become in qml is 2^31 - 1 aka 2147483647, if you increment your int every second, you will have an integer overflow after roughly 68 years.

            so I think you will be fine.

            V Offline
            V Offline
            vicky_mac
            wrote on last edited by vicky_mac
            #5

            @J-Hilk
            Ok that's enough I think.

            One more question what will happen to scrolleft().

            If I keep on incrementing these, will there be any increase in runtime memory or processor load?

            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