Unsolved updating a chart using the signal slot mechanism
-
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 :
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
-
@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
-
@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 ?
-
@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. -
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.
-
@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