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. updating a chart using the signal slot mechanism
Qt 6.11 is out! See what's new in the release blog

updating a chart using the signal slot mechanism

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 784 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.
  • A Offline
    A Offline
    aftalib
    wrote on last edited by
    #1

    Hello, im working on a polar chart and a cartesian chart with some data i load in during the initialization of my project. Here is what it looks like : af3f6ab5-2aeb-48b1-acd9-8519918cdd77-image.png

    The first two columns of the tableview on the left are used in the polar chart on the right.

    I would like that, when the user changes a value in these columns, it updates on the chart too.

    I tried using the data changed signal, like this :

         connect(ui->tableEd->model(),SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),this,SLOT(on_tableEd_activated(const QModelIndex&, const QModelIndex&)));
    
    

    i can get the value that has changed with this, but i cant update the QLineSeries with it : i get a segmentation fault error every time i try to replace my QLineSeries value with the changed value.

    does anyone would know how to do this ?

    thank you in advance

    jsulmJ 1 Reply Last reply
    0
    • A aftalib

      Hello, im working on a polar chart and a cartesian chart with some data i load in during the initialization of my project. Here is what it looks like : af3f6ab5-2aeb-48b1-acd9-8519918cdd77-image.png

      The first two columns of the tableview on the left are used in the polar chart on the right.

      I would like that, when the user changes a value in these columns, it updates on the chart too.

      I tried using the data changed signal, like this :

           connect(ui->tableEd->model(),SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),this,SLOT(on_tableEd_activated(const QModelIndex&, const QModelIndex&)));
      
      

      i can get the value that has changed with this, but i cant update the QLineSeries with it : i get a segmentation fault error every time i try to replace my QLineSeries value with the changed value.

      does anyone would know how to do this ?

      thank you in advance

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @aftalib said in updating a chart using the signal slot mechanism:

      i get a segmentation fault error every time i try to replace my QLineSeries value with the changed value.

      Please post the code and stack trace would also be good

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @aftalib said in updating a chart using the signal slot mechanism:

        i get a segmentation fault error every time i try to replace my QLineSeries value with the changed value.

        Please post the code and stack trace would also be good

        A Offline
        A Offline
        aftalib
        wrote on last edited by aftalib
        #3

        @jsulm here is the code i wrote in order to replace the qlineseries with the changed value :

        void editant::on_tableEd_activated(const QModelIndex& index, const QModelIndex& index2)
        {
        
                    QVariant indexval = index.data();
                    qDebug() << index.row();
        
                    const double valueDouble = indexval.toDouble();
                    if (index.column() == 0) {
                        m_edAz->replace(index.row(),valueDouble);
                        qDebug() << "boucle";
                        qDebug() << valueDouble;
                    }
                    else if (index.column() == 1) {
                        m_edAmp->replace(index.row(),valueDouble);
                    }
                    int valindex = index.row();
                    series1->replace(valindex,m_edAz->at(valindex),m_edAmp->at(valindex));
                    
        
        
        
        
        
        
        }
        

        by stack trace do you mean the list of errors i get when i stumble on the segmentation fault ?

        jsulmJ 1 Reply Last reply
        0
        • A aftalib

          @jsulm here is the code i wrote in order to replace the qlineseries with the changed value :

          void editant::on_tableEd_activated(const QModelIndex& index, const QModelIndex& index2)
          {
          
                      QVariant indexval = index.data();
                      qDebug() << index.row();
          
                      const double valueDouble = indexval.toDouble();
                      if (index.column() == 0) {
                          m_edAz->replace(index.row(),valueDouble);
                          qDebug() << "boucle";
                          qDebug() << valueDouble;
                      }
                      else if (index.column() == 1) {
                          m_edAmp->replace(index.row(),valueDouble);
                      }
                      int valindex = index.row();
                      series1->replace(valindex,m_edAz->at(valindex),m_edAmp->at(valindex));
                      
          
          
          
          
          
          
          }
          

          by stack trace do you mean the list of errors i get when i stumble on the segmentation fault ?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aftalib said in updating a chart using the signal slot mechanism:

          by stack trace do you mean the list of errors i get when i stumble on the segmentation fault ?

          No, I mean the stack trace in debugger showing what was called before the crash.
          You should also at least mention in which line exactly it is crashing. You are using several pointers which could be invalid.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          0
          • jsulmJ jsulm

            @aftalib said in updating a chart using the signal slot mechanism:

            by stack trace do you mean the list of errors i get when i stumble on the segmentation fault ?

            No, I mean the stack trace in debugger showing what was called before the crash.
            You should also at least mention in which line exactly it is crashing. You are using several pointers which could be invalid.

            A Offline
            A Offline
            aftalib
            wrote on last edited by
            #5

            @jsulm e22638f1-ef0e-4e25-98eb-66748e1e3ef4-image.png

            here's a screenschot of my debugger.

            the line that it is crashing is

            series1->replace(valindex,m_edAz->at(valindex),m_edAmp->at(valindex));
            

            it seems that i cant access any of the chart elements. even when i try to remove my series from my chart, i get a segmentation fault error.

            jsulmJ 1 Reply Last reply
            0
            • A aftalib

              @jsulm e22638f1-ef0e-4e25-98eb-66748e1e3ef4-image.png

              here's a screenschot of my debugger.

              the line that it is crashing is

              series1->replace(valindex,m_edAz->at(valindex),m_edAmp->at(valindex));
              

              it seems that i cant access any of the chart elements. even when i try to remove my series from my chart, i get a segmentation fault error.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @aftalib said in updating a chart using the signal slot mechanism:

              series1->replace(valindex,m_edAz->at(valindex),m_edAmp->at(valindex));

              Check that:

              • series1 is a valid pointer
              • m_edAz is a valid pointer
              • m_edAmp is a valid pointer
              • valindex is not out of bounds in m_edAz, m_edAmp and series1

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              4

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved