In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to write the Qt multi-browser kernel". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to write the Qt multi-browser kernel.
I. Preface
Here is part of the code:
/ / Common initialization browser control configuration void WebHelper::initWebSetting () {/ / Global configuration only needs to be set once static bool isInit = false; if (! isInit) {isInit = true;#ifdef webkit QWebSettings * webSetting = QWebSettings::globalSettings (); webSetting- > setAttribute (QWebSettings::JavascriptEnabled, true); webSetting- > setAttribute (QWebSettings::PluginsEnabled, true); webSetting- > setAttribute (QWebSettings::JavascriptCanOpenWindows, true) # elif webengine QWebEngineSettings * webSetting = QWebEngineSettings::globalSettings (); webSetting- > setAttribute (QWebEngineSettings::JavascriptEnabled, true); webSetting- > setAttribute (QWebEngineSettings::PluginsEnabled, true); webSetting- > setAttribute (QWebEngineSettings::JavascriptCanOpenWindows, true); # endif}} / / General browser components load void frmMapBoundary::loadMap (bool tool) {QString content; QString fileName = QString ("% 1/map_web.html") .arg (AppPath) QString url = "file:///" + fileName; baidu- > reset (); baidu- > setMapZoom (10); baidu- > setShowOverlayTool (tool); / / set the default center point coordinates, which is recommended as baidu- > setMapCenterPoint (" 121.414 < 31.1828 ") / / if you load content, you need to set not to store the file / / ie kernel and load it in load on linux / / find that Qt5.5 webkit also needs to be loaded in file # ifdef savehtmlfile baidu- > setSaveFile (true); # else baidu- > setSaveFile (false); # endif baidu- > setFileName (fileName); content = baidu- > newMap () / / here are two ways to load a web page. Load the web page file if the content is empty or load the content otherwise / / generally, it is recommended to load the content for the sake of confidentiality, so that the generated web page file / / the webkit kernel on linux may need to load if (baidu- > getSaveFile ()) {# if (defined webkit) | | (defined webengine) webView- > load (QUrl (url)) as load. # elif webie webView- > dynamicCall ("Navigate (const QString&)", url); # endif} else {QUrl baseUrl (QString ("% 1 /") .arg (AppPath)); # if (defined webkit) | | (defined webengine) webView- > setHtml (content, baseUrl) # endif}} / / General data interaction class / / you need to customize classes inherited from QObject to receive QWebEngineView interaction data, otherwise you will print a lot of annoying information class WebJsData: public QObject {Q_OBJECTpublic: static WebJsData * Instance (); explicit WebJsData (QObject * parent = 0) Public slots: / / defines two parameters, thus covering all cases where the type representation type is equivalent to the unique identification void receiveData (const QString & type, const QVariant & data); signals: void receiveDataFromJs (const QString & type, const QVariant & data);}; WebJsData * WebJsData::Instance () {static WebJsData self; return & self } WebJsData::WebJsData (QObject * parent) {} void WebJsData::receiveData (const QString & type, const QVariant & data) {/ / can be recombed here and then send out the signal emit receiveDataFromJs (type, data).
Both online map and offline map modes are supported.
Support webkit kernel, webengine kernel and IE kernel at the same time.
Multiple dimension points can be set, including name, address, longitude and latitude.
You can set whether the map can be clicked, dragged, or scrolled.
You can set the protocol version, secret key, theme style, central coordinates, central city, geocoding location, and so on.
Can set the map zoom scale and level, thumbnails, scale, road information and other controls visible.
Support map interaction, such as mouse press to get the latitude and longitude of the corresponding location.
Support to query the route, you can set the starting point, end point, route mode, route mode, route scheme (minimum time, least transfer, least walk, do not take the subway, shortest distance, avoid highway).
Can display dots, lines and surfaces tools, and can draw lines, points, rectangles, circles and so on directly on the map.
Administrative divisions can be set up, a certain urban area drawing layer can be specified, and the online map automatically outputs the administrative division boundary points to the js file for offline map use.
Multiple coverings can be added statically or dynamically. Support points, broken lines, polygons, rectangles, circles, arcs, point aggregations, etc.
The function interface is friendly and unified, and it is easy to use, just one class.
Support js dynamic interaction to add points, delete points, clear points, reset points, no need to refresh the page.
Support any Qt version, any system, any compiler.
Third, effect picture
At this point, I believe you have a deeper understanding of "how to write the Qt multi-browser kernel". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.