Properly changing the displayed chart in a QChartView
Unsolved
General and Desktop
-
I am trying to change the displayed chart in a QChartView, but each time the program fails in some form.
void MainWindow::updateRollResult(QString rollResult, QChart* chart){ ui->rollResultLabel->setText("Sum of all dice rolls: " + rollResult); ui->diceChart = new QChartView(chart); ui->diceChart->repaint(); }
This code causes the QChartView to display nothing. However, I have tried things such as deleting the current chart given certain conditions, or setting the chartView's chart to a different chart, but those cause the program to crash after one or two operations. Why might this happen, and how do I correctly change the graph?
-
@BradDev20 said in Properly changing the displayed chart in a QChartView:
ui->diceChart = new QChartView(chart);
Are you sure you do it here?
-
Hi,
Why not use QChartView::setChart ?
What you currently do is just replacing the object pointed by
ui->diceView
by a different one, but that is all.