我用qt Creator创建了一个UI界面,在这个界面上只有一个按钮和一个小部件(我们分别称之为按钮和char_container);
我需要在char_container中通过编程方式添加一个图表视图。
我没有改变默认布局。
我尝试了下面的代码,但它不起作用:
我尝试了下面的代码,但它不起作用:
void MainWindow::button_slot(){
QtCharts::QChart *chart = new QtCharts::QChart();
QtCharts::QChartView *chartView = new QtCharts::QChartView(chart);
chartView->setParent(ui->chart_container);
this.repaint();
}