QLine is not added to all QCharts

121 views Asked by At

I have a QT application and on my window I have graphs and number of graphs are depending on users choice thats why I am using a pointer array to create them. My problem is when I try to add QLineSeries object on my QChart(which allready has QScatterSeries) the line only adding on last chart. Here is the sample of my code :

graph.h

QChart *chartArr[chartLimit];
QLineSeries *lineArr[lineLimit];
QPushButton *nextButton;

public slots:
onnextButtonClicked();

graph.cpp

GraphDialog::GraphDialog(QWidget *parent, Form *formPtr) :
    QDialog(parent),
    ui(new Ui::GraphDialog)

{
...
this->nextbutton = new QPushButton(buttonFrame);
connect(this->nextbutton,SIGNAL(clicked()),this,SLOT(onnextButtonClicked()));
...
}

void Graph::createLine(QString selected_item)
{
if(selected_item == "300")  //seleted_item is the item what user choose on comboBox object
{
this->lineArr[0] = new QLineSeries();
this->lineArr[0]->setName("300-350gr");
this->lineArr[0]->append(QPoint(this->dy,this->y_max));  //variables that app calculated on previous functions. On debug mode this varibales seen calculated succesfully.
this->lineArr[0]->append(QPoint(this->dy,0));
}
}

void Graph::fillCharts(int index,QString selected_item)
{
if(selected_item == "300")
{
this->chartArr[index]->addSeries(this->lineArr[0]);
this->chartArr[index]->createDefaultAxes();
}
}

void Graph::onnextButtonClicked(){
QString selected_item = this->comboBox->currentText();
if(selected_item == "300"){
this->createLine("300");
for(int i = 0 ;i<this->chartIndexList.count();i++){  //this list holds my chart indexes and when I debug I could see list filled succesfully
if(this->chartIndexList.at(i) != 0){
this->fillCharts(this->chartIndexList.at(i),"300");
}
}
}
}

here is the output off my application as you can see my QLine's name added to my first qchart but points are not seen. How can I solve this problem?

0

There are 0 answers