如何在 QT 中根据我的数据自动调整图表大小?

问题描述

我有一个滚动动态图表。当新数据到来时,我看不到图表大小。我可以自动化吗? qt 图表有这样的属性吗? enter image description here

void MainWindow::initChartView()
{
    QChart *chart = new QChart();
    chart->addSeries(series);
    qDebug()<< series;
    QPen green(Qt::red);
    green.setWidth(2);
    series->setPen(green);
    chart->legend()->hide();
    chart->setTitle("deneme");
    chart->setAnimationOptions(QChart::AllAnimations);


    QValueAxis *axisX=new QValueAxis;
    axisX->setTickCount(5);
    axisX->setRange(0,2);
    chart->addAxis(axisX,Qt::AlignBottom);
    series->attachAxis(axisX);


    QValueAxis *axisY = new QValueAxis;
    axisY->setTickCount(5);
    axisY->setRange(0,2);
    chart->addAxis(axisY,Qt::AlignLeft);
    series->attachAxis(axisY);

    QChartView *chartView = new QChartView(chart);
    chartView->setRenderHint(QPainter::Antialiasing);
    this->setCentralWidget(chartView);
}

enter image description here

解决方法

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

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

小编邮箱: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...