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. waveform code getting crashed.
Forum Update on Monday, May 27th 2025

waveform code getting crashed.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 268 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.
  • T Offline
    T Offline
    Tom44
    wrote on last edited by
    #1

    Hi

    I have used line series to create waveform. I am using two line series one after.

    code:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtCharts 2.0
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        property var i: 0
        property var j: 0
        property var k: 0
        property var line1
        property var line2
        property var points:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,17.5,17.8,18,18,18.1,18.15,18,17.5,17,16.5,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]
        ChartView {
            id:myChart
            title: "Line"
            anchors.fill: parent
            antialiasing: true
            ValueAxis {
                id: xAxis
                min: 0
                max: 100;
            }
    
            ValueAxis {
                id: yAxis
                min: 0
                max: 50
            }
    
                 Component.onCompleted: { line1= myChart.createSeries(ChartView.SeriesTypeLine,"series1",xAxis,yAxis)
                                          line2= myChart.createSeries(ChartView.SeriesTypeLine,"series2",xAxis,yAxis)
                                         }
        }
        Timer {
            interval: 50; running: true;
            repeat: true
            onTriggered:
            {
                i = i + 1
                if(i > 100)
                {
                    i = 0
                    k = 0
                    if(j===0){j = 1;/*myChart.removeSeries(line2);*//*line2 = myChart.createSeries(ChartView.SeriesTypeLine,"series2",xAxis,yAxis);*/}
                    else {    j = 0;/*myChart.removeSeries(line1);*//*line1 = myChart.createSeries(ChartView.SeriesTypeLine,"series1",xAxis,yAxis);*/}
                }
    
    
                if(j===1)
                {
    
                if(k === points.length){k=0}
                line1.remove(0)
                line2.append(i,points[k])
                    k++;
    
                }
                else{
                    if(k === points.length){k=0}
    
                line2.remove(0)
                line1.append(i,points[k])
                    k++;
                }
            }
        }
    }
    
    

    It runs for some time and gets crashed probably due to append() api.
    How can I solve this?

    K 1 Reply Last reply
    0
    • T Tom44

      Hi

      I have used line series to create waveform. I am using two line series one after.

      code:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtCharts 2.0
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          property var i: 0
          property var j: 0
          property var k: 0
          property var line1
          property var line2
          property var points:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,17.5,17.8,18,18,18.1,18.15,18,17.5,17,16.5,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1]
          ChartView {
              id:myChart
              title: "Line"
              anchors.fill: parent
              antialiasing: true
              ValueAxis {
                  id: xAxis
                  min: 0
                  max: 100;
              }
      
              ValueAxis {
                  id: yAxis
                  min: 0
                  max: 50
              }
      
                   Component.onCompleted: { line1= myChart.createSeries(ChartView.SeriesTypeLine,"series1",xAxis,yAxis)
                                            line2= myChart.createSeries(ChartView.SeriesTypeLine,"series2",xAxis,yAxis)
                                           }
          }
          Timer {
              interval: 50; running: true;
              repeat: true
              onTriggered:
              {
                  i = i + 1
                  if(i > 100)
                  {
                      i = 0
                      k = 0
                      if(j===0){j = 1;/*myChart.removeSeries(line2);*//*line2 = myChart.createSeries(ChartView.SeriesTypeLine,"series2",xAxis,yAxis);*/}
                      else {    j = 0;/*myChart.removeSeries(line1);*//*line1 = myChart.createSeries(ChartView.SeriesTypeLine,"series1",xAxis,yAxis);*/}
                  }
      
      
                  if(j===1)
                  {
      
                  if(k === points.length){k=0}
                  line1.remove(0)
                  line2.append(i,points[k])
                      k++;
      
                  }
                  else{
                      if(k === points.length){k=0}
      
                  line2.remove(0)
                  line1.append(i,points[k])
                      k++;
                  }
              }
          }
      }
      
      

      It runs for some time and gets crashed probably due to append() api.
      How can I solve this?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Tom44

      Do you run the app in Qt creator with debugger?
      If not, this would be definitely the next step to try.

      Also you can use https://doc.qt.io/qt-5/qtquick-debugging.html . The output shall be shown in the Application output pane of creator.

      Which OS are you on?
      Is the application also compiled for that OS?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      3
      • T Offline
        T Offline
        Tom44
        wrote on last edited by
        #3

        Hi @koahnig
        Thanks for help!!
        Problem is solved

        This problem was due to remove(0).

        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