Browse Source

first

master
tianzhendong 1 year ago
commit
d4bb513d23
  1. 12
      .gitignore
  2. 71
      CMakeLists.txt
  3. 32
      FlightDataAnalysis_zh.ts
  4. 32
      LibMiniBlink.pro
  5. BIN
      miniblink-20230412.zip
  6. BIN
      node.dll
  7. BIN
      resources/MAP.png
  8. 1
      resources/Map.rc
  9. 7
      resources/icons.qrc
  10. 1
      resources/map-black.svg
  11. 1
      resources/map-blue.svg
  12. BIN
      resources/map.ico
  13. 1
      resources/map.svg
  14. 31
      src/main.cpp
  15. 103
      src/mapwidget.cpp
  16. 46
      src/mapwidget.h
  17. 79
      src/mapwidget.ui
  18. 77
      src/webwidget.cpp
  19. 49
      src/webwidget.h
  20. 1548
      src/wke.h
  21. BIN
      wmts.exe

12
.gitignore

@ -0,0 +1,12 @@
Build/
*.user
# *.dll
*.a
Makefile
lib*.so*
.idea/
*build*/
miniblink-20230412/

71
CMakeLists.txt

@ -0,0 +1,71 @@
cmake_minimum_required(VERSION 3.5)
PROJECT(Map LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
if(WIN32)
MESSAGE(STATUS "WIN32")
set(CMAKE_PREFIX_PATH "C:/DevelopEnv/Qt/5.15.2/mingw81_64")
set(QT_VERSION "5.15.2")
elseif(UNIX)
MESSAGE(STATUS "UNIX")
set(CMAKE_PREFIX_PATH "/home/tian/Qt5.12.3/5.12.3/gcc_64")
# solve program: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
set(QT_VERSION "5.12.3")
set(CMAKE_CXX_FLAGS -pthread)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# qt
find_package(Qt5 COMPONENTS
Core
Gui
Widgets
Websockets
LinguistTools
REQUIRED)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) #
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Libs) #
include_directories(${PROJECT_SOURCE_DIR}/src)
FILE(GLOB_RECURSE APP_HEADER ${PROJECT_SOURCE_DIR}/Src/*.h)
FILE(GLOB_RECURSE APP_SRC ${PROJECT_SOURCE_DIR}/Src/*.cpp)
FILE(GLOB_RECURSE FORMS ${PROJECT_SOURCE_DIR}/Src/*.ui)
FILE(GLOB_RECURSE RESOURCE_FILES ${PROJECT_SOURCE_DIR}/resources/*.qrc ${PROJECT_SOURCE_DIR}/resources/*.rc)
#
# 使
set(TS_FILES)
set(QM_FILES)
set(PROJECT_SOURCES ${APP_SRC} ${COMMONMODULE_SRC} ${DATA_SRC} ${DECODEROUTE_SRC} ${FILEOPERATOR_SRC} ${OVERLOAD_SRC} ${PLOT_SRC} ${PYTHONPLOT_SRC} ${MATLABPLOT_SRC} ${UI_SRC}
${FORMS})
#
list(APPEND TS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/FlightDataAnalysis_zh.ts)
# CMakeFiles
set_source_files_properties(${TS_FILES}
PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}
)
qt5_create_translation(QM_FILES ${TS_FILES} ${PROJECT_SOURCES})
#
add_custom_target(lupdate_task DEPENDS ${TS_FILES})
#
add_custom_target(lrelease_task DEPENDS ${QM_FILES})
SET(CMAKE_BUILD_TYPE "Release")
add_executable(${PROJECT_NAME} ${APP_SRC} ${APP_HEADER}
${FORMS} ${RESOURCE_FILES} ${TS_FILES})
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::WebSockets
)

32
FlightDataAnalysis_zh.ts

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<context>
<name>MapWidget</name>
<message>
<location filename="src/mapwidget.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/mapwidget.ui" line="41"/>
<source>GroupBox</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/mapwidget.ui" line="47"/>
<source>serverListen</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/mapwidget.ui" line="54"/>
<source>CallWMTS</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/mapwidget.ui" line="61"/>
<source>PushButton</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

32
LibMiniBlink.pro

@ -0,0 +1,32 @@
QT += core gui websockets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += $$PWD
SOURCES += \
$$PWD/src/main.cpp \
$$PWD/src/mapwidget.cpp \
$$PWD/src/webwidget.cpp
HEADERS += \
$$PWD/src/mapwidget.h \
$$PWD/src/webwidget.h
FORMS += \
$$PWD/src/mapwidget.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RC_ICONS += $$PWD/resources/map.ico
RESOURCES += \
resources/icons.qrc

BIN
miniblink-20230412.zip

Binary file not shown.

BIN
node.dll

Binary file not shown.

BIN
resources/MAP.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

1
resources/Map.rc

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "map.ico"

7
resources/icons.qrc

@ -0,0 +1,7 @@
<RCC>
<qresource prefix="/">
<file>map.svg</file>
<file>map-black.svg</file>
<file>map-blue.svg</file>
</qresource>
</RCC>

1
resources/map-black.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1684492721623" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3914" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"><path d="M768 275.84c0 34.56-16.96 81.92-42.24 133.12C653.12 556.48 512 736 512 736s-141.12-179.52-213.76-327.04C272.96 357.76 256 310.4 256 275.84 256 141.12 370.56 32 512 32s256 109.12 256 243.84z m-179.2 7.68c0-41.6-34.24-75.52-76.8-75.52s-76.8 33.92-76.8 75.52 34.24 75.2 76.8 75.2 76.8-33.6 76.8-75.2z" fill="#8a8a8a" p-id="3915"></path><path d="M983.744 321.088l-208.32 55.552c16.384-40.288 24.576-73.6 24.576-100.8C800 123.744 670.816 0 512 0S224 123.744 224 275.84c0 27.2 8.192 60.512 24.608 100.8l-208.352-55.552A32.032 32.032 0 0 0 0 352v576a32 32 0 0 0 23.744 30.912l240 64c2.688 0.704 5.344 1.024 8 1.056l0.224 0.032h0.32c2.624-0.064 5.28-0.384 7.968-1.088L512 961.12l231.744 61.792c2.688 0.704 5.344 1.024 8 1.056l0.224 0.032h0.32c2.624-0.064 5.28-0.384 7.968-1.088l240-64A32 32 0 0 0 1024 928V352a32.032 32.032 0 0 0-40.256-30.912zM256 954.624l-192-51.2v-509.76l192 51.2v509.76z m240-55.488L288 954.624V458.56c75.808 140 193.472 290.336 198.848 297.184 0.704 0.896 1.728 1.216 2.496 2.016 1.056 1.088 1.664 2.4 2.88 3.36 1.152 0.928 2.528 1.312 3.776 2.048v135.936z m240 55.488l-208-55.488V763.2c1.248-0.736 2.624-1.12 3.776-2.048 1.216-0.96 1.824-2.272 2.88-3.36 0.768-0.8 1.792-1.12 2.496-2.016 5.376-6.848 123.04-157.184 198.848-297.184v496z m-38.912-559.872l-0.064 0.064c-52.064 105.824-141.6 230.272-185.024 288.32-43.424-58.048-132.896-182.4-185.024-288.32l-0.064-0.064C294.752 329.6 288 294.144 288 275.84 288 159.04 388.48 64 512 64s224 95.04 224 211.84c0 18.304-6.72 53.76-38.912 118.912zM960 903.424l-192 51.2v-509.76l192-51.2v509.76z" fill="#8a8a8a" p-id="3916"></path><path d="M512 176c-60 0-108.8 48.224-108.8 107.52 0 59.104 48.8 107.2 108.8 107.2s108.8-48.096 108.8-107.2c0-59.296-48.8-107.52-108.8-107.52z m0 150.72c-24.704 0-44.8-19.392-44.8-43.2 0-24 20.096-43.52 44.8-43.52s44.8 19.52 44.8 43.52c0 23.808-20.096 43.2-44.8 43.2z" fill="#8a8a8a" p-id="3917"></path></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

1
resources/map-blue.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1684492721623" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3914" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"><path d="M768 275.84c0 34.56-16.96 81.92-42.24 133.12C653.12 556.48 512 736 512 736s-141.12-179.52-213.76-327.04C272.96 357.76 256 310.4 256 275.84 256 141.12 370.56 32 512 32s256 109.12 256 243.84z m-179.2 7.68c0-41.6-34.24-75.52-76.8-75.52s-76.8 33.92-76.8 75.52 34.24 75.2 76.8 75.2 76.8-33.6 76.8-75.2z" fill="#1296db" p-id="3915"></path><path d="M983.744 321.088l-208.32 55.552c16.384-40.288 24.576-73.6 24.576-100.8C800 123.744 670.816 0 512 0S224 123.744 224 275.84c0 27.2 8.192 60.512 24.608 100.8l-208.352-55.552A32.032 32.032 0 0 0 0 352v576a32 32 0 0 0 23.744 30.912l240 64c2.688 0.704 5.344 1.024 8 1.056l0.224 0.032h0.32c2.624-0.064 5.28-0.384 7.968-1.088L512 961.12l231.744 61.792c2.688 0.704 5.344 1.024 8 1.056l0.224 0.032h0.32c2.624-0.064 5.28-0.384 7.968-1.088l240-64A32 32 0 0 0 1024 928V352a32.032 32.032 0 0 0-40.256-30.912zM256 954.624l-192-51.2v-509.76l192 51.2v509.76z m240-55.488L288 954.624V458.56c75.808 140 193.472 290.336 198.848 297.184 0.704 0.896 1.728 1.216 2.496 2.016 1.056 1.088 1.664 2.4 2.88 3.36 1.152 0.928 2.528 1.312 3.776 2.048v135.936z m240 55.488l-208-55.488V763.2c1.248-0.736 2.624-1.12 3.776-2.048 1.216-0.96 1.824-2.272 2.88-3.36 0.768-0.8 1.792-1.12 2.496-2.016 5.376-6.848 123.04-157.184 198.848-297.184v496z m-38.912-559.872l-0.064 0.064c-52.064 105.824-141.6 230.272-185.024 288.32-43.424-58.048-132.896-182.4-185.024-288.32l-0.064-0.064C294.752 329.6 288 294.144 288 275.84 288 159.04 388.48 64 512 64s224 95.04 224 211.84c0 18.304-6.72 53.76-38.912 118.912zM960 903.424l-192 51.2v-509.76l192-51.2v509.76z" fill="#1296db" p-id="3916"></path><path d="M512 176c-60 0-108.8 48.224-108.8 107.52 0 59.104 48.8 107.2 108.8 107.2s108.8-48.096 108.8-107.2c0-59.296-48.8-107.52-108.8-107.52z m0 150.72c-24.704 0-44.8-19.392-44.8-43.2 0-24 20.096-43.52 44.8-43.52s44.8 19.52 44.8 43.52c0 23.808-20.096 43.2-44.8 43.2z" fill="#1296db" p-id="3917"></path></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
resources/map.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

1
resources/map.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1684492642819" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7486" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48"><path d="M377.6 145.066667c-70.4 23.466667-132.266667 76.8-132.266667 76.8l104.533334 44.8 138.666666-66.133334 21.333334-66.133333s-70.4-8.533333-132.266667 10.666667z m0 0" fill="#333333" p-id="7487"></path><path d="M475.733333 458.666667l-125.866666-110.933334-177.066667-6.4 17.066667 219.733334 93.866666 55.466666 72.533334 230.4 241.066666-256 6.4-132.266666h-128z m0 0" fill="#5C6BC0" p-id="7488"></path><path d="M827.733333 283.733333l-153.6-104.533333L618.666667 234.666667l21.333333 93.866666 104.533333 38.4 59.733334 59.733334 66.133333 49.066666-49.066667 59.733334-93.866666 281.6 149.333333-149.333334 21.333333-198.4-70.4-185.6z m0 0" fill="#333333" p-id="7489"></path><path d="M512 151.466667c198.4 0 360.533333 162.133333 360.533333 360.533333 0 198.4-162.133333 360.533333-360.533333 360.533333-198.4 0-360.533333-162.133333-360.533333-360.533333 0-198.4 162.133333-360.533333 360.533333-360.533333M512 85.333333C277.333333 85.333333 85.333333 277.333333 85.333333 512s192 426.666667 426.666667 426.666667 426.666667-192 426.666667-426.666667S746.666667 85.333333 512 85.333333z m0 0" fill="#333333" p-id="7490"></path></svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

31
src/main.cpp

@ -0,0 +1,31 @@
#include "wke.h"
#include "mapwidget.h"
#include <QApplication>
#include <QFile>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
wkeSetWkeDllPath(L"node.dll");
wkeInitialize();
/* webView在头文件里面声明了是一个wkeWebView类型
wkeCreateWebWindow是创建一个带真实窗口的wkeWebView
wkeWindowType type:
WKE_WINDOW_TYPE_POPUP
WKE_WINDOW_TYPE_TRANSPARENTmb内部通过layer window实现
WKE_WINDOW_TYPE_CONTROL parent需要被设置
parent窗口的句柄, QT里面可以调用窗口的winID()
*/
MapWidget w;
w.show();
// WebWidget *w = new WebWidget("www.baidu.com");
int ret = a.exec();
wkeFinalize();
return ret;
}

103
src/mapwidget.cpp

@ -0,0 +1,103 @@
#include "mapwidget.h"
#include "ui_mapwidget.h"
#include <QWebSocket>
MapWidget::MapWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MapWidget)
{
ui->setupUi(this);
this->showMaximized();
m_pWebWidget = new WebWidget("D:/4_Code/Leaflet/demo.html", this);
ui->verticalLayout->addWidget(m_pWebWidget);
}
MapWidget::~MapWidget()
{
delete ui;
}
void MapWidget::on_btn_callWmts_clicked()
{
m_pWebWidget->callJsFunction("printInformation", "tian");
return;
m_pWebWidget->startWmts();
}
void MapWidget::on_btn_server_clicked()
{
if(!m_pWebSocketServer)
{
//构造:QWebSocketServer(const QString& serverName,QWebSocketServer::SslMode secureMode,QObject *parent=nullptr)
//使用给定的serverName构造一个新的QWebSocketServer。
//该服务器名称将在HTTP握手阶段被用来识别服务器。它可以为空,此时不会将服务器名称发送给客户端。
//SslMode指示服务器是通过wss(SecureMode)还是ws(NonSecureMode)运行
//QWebSocketServer::SecureMode服务器以安全模式运行(通过wss)
m_pWebSocketServer = new QWebSocketServer("Server", QWebSocketServer::NonSecureMode, this);
}
// QHostAddress address = QHostAddress("127.0.0.1");
int port = 12345;
QString s;
if(!m_pWebSocketServer->listen(QHostAddress::Any, port))
{
s = "websocket listen error";
}
else
{
s = QString("websocket listen on port %1").arg(port);
connect(m_pWebSocketServer, &QWebSocketServer::newConnection, this, &MapWidget::onNewConnection);
connect(m_pWebSocketServer, &QWebSocketServer::closed, this, &MapWidget::onWebSocketClosed);
}
qDebug() << s;
m_pWebWidget->callJsFunction("printInformation", s);
}
void MapWidget::onNewConnection()
{
QWebSocket *socket = m_pWebSocketServer->nextPendingConnection();
if(!socket)
return;
clientList.push_back(socket);
qDebug() << QString("[New Connect] Address:%1 Port:%2")
.arg(socket->peerAddress().toString())
.arg(socket->peerPort());
//收到消息
connect(socket, &QWebSocket::textMessageReceived, this, [&](const QString & msg)
{
qDebug() << msg;
m_pWebWidget->callJsFunction(msg);
});
//发送消息
connect(this, &MapWidget::doSendMessage, socket, &QWebSocket::sendTextMessage);
//断开连接,释放
connect(socket, &QWebSocket::disconnected, this, [&, socket]()
{
clientList.removeAll(socket);
socket->deleteLater();
});
}
void MapWidget::onWebSocketClosed()
{
}
void MapWidget::on_pushButton_clicked()
{
static int cnt = 0;
emit doSendMessage(QString("send message %1").arg(cnt++));
}
void MapWidget::on_btn_clear_clicked()
{
static int cnt1 = 3;
m_pWebWidget->callJsFunction("clearOneLine", QString::number(cnt1--));
}

46
src/mapwidget.h

@ -0,0 +1,46 @@
#ifndef MAPWIDGET_H
#define MAPWIDGET_H
#include <QWebSocketServer>
#include <QWidget>
#include "webwidget.h"
namespace Ui
{
class MapWidget;
}
class MapWidget : public QWidget
{
Q_OBJECT
public:
explicit MapWidget(QWidget *parent = nullptr);
~MapWidget();
signals:
void doSendMessage(const QString & s);
private slots:
void on_btn_callWmts_clicked();
void on_btn_server_clicked();
void onNewConnection();
void onWebSocketClosed();
void on_pushButton_clicked();
void on_btn_clear_clicked();
private:
Ui::MapWidget *ui;
WebWidget * m_pWebWidget = nullptr;
QWebSocketServer *m_pWebSocketServer = nullptr;
QList<QWebSocket*> clientList;
};
#endif // MAPWIDGET_H

79
src/mapwidget.ui

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapWidget</class>
<widget class="QWidget" name="MapWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1386</width>
<height>1030</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="btn_server">
<property name="text">
<string>serverListen</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="btn_callWmts">
<property name="text">
<string>CallWMTS</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="btn_clear">
<property name="text">
<string>清除所有曲线</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

77
src/webwidget.cpp

@ -0,0 +1,77 @@
#include "webwidget.h"
#include "qapplication.h"
#include <QHBoxLayout>
#include <QDebug>
WebWidget::WebWidget(const QString& url, QWidget *_parent) : QWidget(_parent)
{
webView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)_parent->winId(), 0, 0, this->width(), this->height());
wkeShowWindow(webView, TRUE);
QString _sUrl = url;
if(_sUrl.isEmpty())
_sUrl = "www.baidu.com";
wkeLoadURL(webView, _sUrl.toUtf8());
// connect()
}
WebWidget::~WebWidget()
{
qDebug() << "in del";
}
void WebWidget::loadUrl(const QString& url)
{
QString _sUrl = url;
if(_sUrl.isEmpty())
_sUrl = "www.baidu.com";
wkeLoadURL(webView, _sUrl.toLocal8Bit().data());
}
void WebWidget::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
wkeResize(webView, this->width(), this->height());
QPoint pos = this->mapToGlobal(QPoint(0, 0));
wkeMoveWindow(webView, 0, 0, this->width() + pos.x(), this->height() + pos.y() / 2);
}
void WebWidget::statusFeedbackSlot()
{
}
void WebWidget::callJsFunction(const QString &sFunctionName, const QString &sPara)
{
QString s = sFunctionName + "(\"" + sPara + "\");";
wkeRunJS(webView, s.toUtf8());
}
void WebWidget::onMove()
{
QPoint pos = this->mapToGlobal(QPoint(0, 0));
wkeMoveWindow(webView, pos.x(), pos.y(), this->width(), this->height());
}
void WebWidget::slotProcessQuit(int, QProcess::ExitStatus )
{
if(m_pWmtsProcess)
{
disconnect(m_pWmtsProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotProcessQuit(int, QProcess::ExitStatus)));
// 负责进程间通信
disconnect(m_pWmtsProcess, &QProcess::readyReadStandardError, this, &WebWidget::statusFeedbackSlot);
disconnect(m_pWmtsProcess, &QProcess::readyReadStandardOutput, this, &WebWidget::statusFeedbackSlot);
m_pWmtsProcess->deleteLater();
m_pWmtsProcess = nullptr;
}
}
void WebWidget::startWmts()
{
if(m_pWmtsProcess != nullptr)
return;
m_pWmtsProcess = new QProcess;
QString path = QCoreApplication::applicationDirPath();
m_pWmtsProcess->setProgram(path + "/wmts.exe");
m_pWmtsProcess->start(QProcess::ReadWrite);
connect(m_pWmtsProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotProcessQuit(int, QProcess::ExitStatus)));
// 负责进程间通信
connect(m_pWmtsProcess, &QProcess::readyReadStandardError, this, &WebWidget::statusFeedbackSlot);
connect(m_pWmtsProcess, &QProcess::readyReadStandardOutput, this, &WebWidget::statusFeedbackSlot);
}

49
src/webwidget.h

@ -0,0 +1,49 @@
#ifndef WEBWIDGET_H
#define WEBWIDGET_H
#include <QWidget>
#include <QResizeEvent>
#include <QFileInfo>
#include "wke.h"
#include <QProcess>
class WebWidget : public QWidget
{
Q_OBJECT
public:
explicit WebWidget(const QString& url = "", QWidget *parent = 0);
~WebWidget();
/**
* @brief loadUrl
* @param url url
*/
void loadUrl(const QString &url);
void onMove();
void startWmts();
/**
* @brief callJsFunction js中的函数
* @param sFunctionName
* @param sPara a和bQString("%1,%2").arg(a).arg(b)
*/
void callJsFunction(const QString &sFunctionName, const QString &sPara = "");
signals:
protected:
void resizeEvent(QResizeEvent *event);
public slots:
void statusFeedbackSlot();
void slotProcessQuit(int exitCode, QProcess::ExitStatus stuts);
private:
wkeWebView webView;
QProcess *m_pWmtsProcess = nullptr;
};
#endif // WEBWIDGET_H

1548
src/wke.h

File diff suppressed because it is too large

BIN
wmts.exe

Binary file not shown.
Loading…
Cancel
Save