在qt的mysql数据库中如何调用数据到图表

请问如何在qt的sqlite数据库中如何调用数据到图表,例如调用priceIn和priceOut作为数据来作为坐标数据

QSqlDatabase dbCommodity = QSqlDatabase::addDatabase("QSQLITE");
dbCommodity.setDatabaseName("../commodity.db");//建立数据库
if ( !dbCommodity.open())
{
    QMessageBox::warning(this, "error", "cannot open");
}
QSqlQuery queryCommodity(dbCommodity);
queryCommodity.exec("create table wareHouse("workOrg QString,currentStore int,priceIn double,priceOut double);");



void getLineSeries(QLineSeries* series)//调用数据,这里该怎么写?
{
    qreal y1, y2;
    y1 =?;
    y2 =?;

    series->append(y1, y2)
}
//绘制折线图
QT_CHARTS_NAMESPACE::QChart * createLineChart(QLineSeries *series)
{

    QChart *chart = new QChart();
    chart->setTitle("测试line图");

    series->setName("测试曲线");
    getLineSeries(series);//getLineSeries函数调用

    QPen pen;
    pen.setStyle(Qt::DotLine);
    pen.setWidth(2);
    pen.setColor(Qt::red);
    series->setPen(pen);
    chart->addSeries(series);

    QValueAxis *axisX = new QValueAxis();
    axisX->setRange(0, 10);
    axisX->setLabelFormat("%.1f");

    axisX->setTitleText("测试x坐标");

    QValueAxis *axisY = new QValueAxis();
    axisY->setRange(0, 100);
    axisY->setLabelFormat("%.2f");

    axisY->setTitleText("测试y坐标");

    chart->setAxisX(axisX, series);
    chart->setAxisY(axisY, series);

    return chart;
}
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问