How it works…

The old webview system was based on Apple's WebKit engine and only available in Qt 5.5 and its predecessor. Since 5.6, WebKit has been completely abandoned by Qt and replaced with Google's Chromium engine. The API has been completely changed and therefore all the code related to Qt WebKit will not work correctly once migrated to 5.6. If you're new to Qt, it's recommended you skip WebKit and learn the WebEngine API since it is becoming the new standard in Qt.

If you have used Qt's WebKit in the past, this webpage teaches you how to port your old code over to Web Engine: https://wiki.qt.io/Porting_from_QtWebKit_to_QtWebEngine.

In step 16, we connected the loadProgress() signal that belongs to the webview widget to the loading() slot function. The signal will be called automatically when the webview is loading the web page you requested by calling QWebEnginePage::load() in step 17. You can also connect the loadStarted() and loadFinished() signals if you need to.

In step 17, we used the QUrl class to convert the text obtained from the line edit to URL format. By default, the address we inserted will lead to the local path if we do not specify the URL scheme (HTTP, HTTPS, FTP, and so on). We may not be able to load the page if, say, we gave it packtpub.com instead of http://packtpub.com. Therefore, we manually specify a URL scheme for it by calling QUrl::setScheme(). This will ensure the address is properly formatted before passing it to the webview.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset