mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-28 03:09:24 +08:00
实现启动splash画面,实现天历史数据的处理和数据库存贮
This commit is contained in:
57
src/qt/MainWeb.cpp
Normal file
57
src/qt/MainWeb.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "MainWeb.h"
|
||||
|
||||
#include "app/Config.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QLabel>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
void MySplash(MainWeb* mainWin)
|
||||
{
|
||||
//===动态程序启动画面===
|
||||
QPixmap pixmap("./assets/ui/splash.png");
|
||||
QSplashScreen splash(pixmap);
|
||||
splash.show();
|
||||
QCoreApplication::processEvents();
|
||||
QLabel label(&splash);
|
||||
label.setStyleSheet("background-color: gray");
|
||||
label.setGeometry(100, 480, 800, 20);
|
||||
label.show();
|
||||
|
||||
QLabel labelProgress(&splash);
|
||||
labelProgress.setStyleSheet("background-color: rgb(29, 54, 102)");
|
||||
labelProgress.setGeometry(10, 10, 0, 20);
|
||||
labelProgress.show();
|
||||
|
||||
int i = 0;
|
||||
while ((++i)<500)
|
||||
{
|
||||
splash.showMessage(QString("Loading... %1 ms").arg(i), Qt::AlignBottom | Qt::AlignRight, Qt::black);
|
||||
labelProgress.setGeometry(100, 480, i*2*0.8, 20);
|
||||
QThread::msleep(10);
|
||||
}
|
||||
|
||||
splash.finish(mainWin);//程序启动画面结束
|
||||
}
|
||||
|
||||
|
||||
MainWeb::MainWeb()
|
||||
{
|
||||
this->setWindowTitle("光储充站监控与运营管理平台");
|
||||
this->setGeometry(0, 0, 1920, 1080);
|
||||
|
||||
webView.setGeometry(0, 0, 1920, 1080);
|
||||
// 默认设置透明, 解决加载时的白屏闪烁
|
||||
webView.page()->setBackgroundColor(Qt::transparent);
|
||||
webView.setContextMenuPolicy(Qt::NoContextMenu);
|
||||
webView.load(QUrl(Config::option.webSrvUrl.c_str()));
|
||||
//webView.load(QUrl("file:///assets/html/main.html"));
|
||||
//connect(wWebView.get(), &QWebEngineView::loadFinished, this, &MyWidget::slotLoadFinished);
|
||||
//std::string htmlContent = "HelloWorld";
|
||||
//webView->setHtml(htmlContent.c_str(), QUrl("file:///assets/html/"));
|
||||
webView.show();
|
||||
this->setCentralWidget(&webView);
|
||||
|
||||
MySplash(this);
|
||||
this->show();
|
||||
}
|
||||
14
src/qt/MainWeb.h
Normal file
14
src/qt/MainWeb.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <QMainWindow>
|
||||
#include <QtWebEngineWidgets/QWebEngineView>
|
||||
#include <QSplashScreen>
|
||||
|
||||
|
||||
|
||||
|
||||
class MainWeb : public QMainWindow
|
||||
{
|
||||
public:
|
||||
MainWeb();
|
||||
|
||||
QWebEngineView webView;
|
||||
};
|
||||
Reference in New Issue
Block a user