QLine未添加到所有QCharts

问题描述

我有一个QT应用程序,在我的窗口上有图形,图形的数量取决于用户的选择,这就是为什么我使用指针数组创建它们的原因。我的问题是,当我尝试在我的QChart(已经具有QScatterSeries)上添加QLineSeries对象时,仅在最后一个图表上添加该线。这是我的代码示例:

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

如您所见,我的QLine名称已添加到我的第一个qchart中,但看不到积分。我该如何解决这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...