QChart模块柱状图,横坐标是时间,纵坐标是数值。动态刷新-LMLPHP

QT += core gui charts

#include <QtCharts/QChartView>
#include <QtCharts/QBarSeries>
#include <QtCharts/QBarSet>
#include <QtCharts/QBarCategoryAxis>
#include <QtCharts/QValueAxis>
#include <QDateTime>
#include <QTimer>

#include <QtCharts>
   // 创建一个柱状图系列
        QBarSeries *series = new QBarSeries();

        // 创建一个柱状图集,用于存储数据
        QBarSet *set = new QBarSet("数据");

        set->append(400);

        series->append(set);

        // 创建一个类别轴,用于显示时间
        QBarCategoryAxis *axisX = new QBarCategoryAxis();
        axisX->setTitleText("时间");

        QString currentTime = QDateTime::currentDateTime().toString("hh:mm:ss");

        axisX->append(currentTime);


        // 创建一个值轴,用于显示数值
        QVa
08-29 03:42