文件结构
qtchart.pro
QT += core gui webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtchart
TEMPLATE = app
SOURCES += main.cpp
widget.cpp
HEADERS += widget.h
FORMS += widget.ui
RESOURCES +=
html.qrc
widget.cpp
#include "widget.h"
#include "ui_widget.h"
#include
#include
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->webView->load(QUrl("qrc:/chart.html"));
}
Widget::~Widget()
{
delete ui;
}
chart.html
FLOT DEMO哈哈哈
$(function(){setInterval(plot_data,1000);})
var d=[];
var i=0;
function plot_data(){
d.push([i++, Math.random()]);
if(d.length>15) d.shift();
$.plot($("#placeholder"), [d]);
if(i>60){
i=0;d=[];
}
}