简介:最近看见有些同学在汇报项目时,发现做的大屏数据挺好看,甩了平常用Qt开发的界面好几条街,但是对于像我这种不会前端的,又想做出来点大屏数据玩玩,而只靠QWt或QCustomplot或QCharts确实不太容易,经过这个周未两个的捣腾,大致做出了一个LOW,LOW的DEMO。前三篇博客是基础,饼状图、柱状图与表盘图。部分代码如下:
1.头文件
QWebView* view1 = nullptr;
QWebView* view2 = nullptr;
QWebView* view3 = nullptr;
QWebView* view4 = nullptr;
QWebView* view5 = nullptr;
QWebView* view6 = nullptr;
QWebView* viewBig = nullptr;
QTimer* mTimer = nullptr;
2.控件布局
QHBoxLayout* hBig = new QHBoxLayout;
viewBig = new QWebView(this);
viewBig->setContextMenuPolicy(Qt::NoContextMenu);
viewBig->load(QUrl("file:///C:/Users/99658/Desktop/echart/echarts-master/dist/chinaMap1.html"));
w = ui.widgetBig->width();
h = ui.widgetBig->height();
js = QString("resizeDiv(%1,%2)").arg(QString::number(w), QString::number(h));
viewBig->page()->mainFrame()->evaluateJavaScript(js);
hBig->addWidget(viewBig);
hBig->setMargin(0);
ui.widgetBig->setLayout(hBig);
3.数据交互
mTimer = new QTimer(this);
connect(mTimer, &QTimer::timeout, this, [=] {
QDateTime dateTime = QDateTime::currentDateTime();
ui.labelTime->setText("当前时间:"+dateTime.toString("yyyy-MM-dd hh:mm:ss ddd"));
});
mTimer->start(1000);
/*
其他数据交互
*/
4.结果