Extending Qt WebKit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
m (JKSH moved page Extending QtWebKit to Extending Qt WebKit: Module name format)
(Remove non-functioning "toc" command)
Line 2: Line 2:


[[Category:Developing with Qt::QtWebKit]]
[[Category:Developing with Qt::QtWebKit]]
[toc align_right="yes" depth="2"]


'''English''' [[Estenent_QtWebKit|Catalan]] [[Extendiendo_QtWebKit|Spanish]] [http://qt-devnet.developpez.com/tutoriels/qtwebkit/etendre-webkit/ French] [[Extending_Qt_WebKit_Japanese|日本語]]
'''English''' [[Estenent_QtWebKit|Catalan]] [[Extendiendo_QtWebKit|Spanish]] [http://qt-devnet.developpez.com/tutoriels/qtwebkit/etendre-webkit/ French] [[Extending_Qt_WebKit_Japanese|日本語]]

Revision as of 12:18, 17 April 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

English Catalan Spanish French 日本語

Extending Qt WebKit

The QtWebKit module makes it possible for developers to extend and combine features found in Qt and WebKit. This hybrid C++ / Web design is becoming popular for a variety of reasons, including the fact that it allows teams to leverage the large community of skilled web developers.

A series of articles from Qt Quarterly provide a good introduction to the technologies and processes involved.

Build network interfaces

Hybrid designs often require some custom Qt code to handle network interactions. Using a Simple Web Service with Qt uses the MathTran Web service to preview TeX markup entered in a text editor as an image. The 2007 article uses classes that are now obsolete, but it's worth a read.

Add Qt widgets to Web-centric user interfaces

David Boddie's Plugging into the Web shows how to include Qt widgets in Web-centric user interfaces. He begins with the basics of using a QWebView widget to display a Web page:

 int main(int argc, char *argv[])
 {
 QApplication app(argc, argv);
 QWebView view;
 view.load(QUrl("http://www.trolltech.com/"));
 view.show();
 return app.exec();
 }

and goes on to show how to use QWebPluginFactory to create a simple widget to display comma-separated-variable files.

Adding New Protocols to QtWebKit

David's follow-on Adding New Protocols to QtWebKit uses of Qt's network access API with WebKit to turn QWebView into a simple FTP client. Qt's network access API is a technology that aims to replace much, but not all, of the functionality provided by the QHttp and QFtp classes. Although the network access API is a Qt-specific technology, the QtWebKit module integrates this Qt technology with WebKit to enable customization of the browser engine by Qt application developers. It also means that we can control how the browser engine obtains and renders content.

Since QNetworkRequest and QNetworkReply are designed to provide a reusable abstraction for network operations, it seems obvious to use these classes to add FTP support to browsers written using QtWebKit. To do this, we first need to examine the network access classes before we see how the QtWebKit module uses them to manage network operations.

Here's how he replaces an existing network manager for a QWebPage by subclassing QNetworkAccessManager and reimplementing its createRequest() function to check for URLs with the ftp scheme.

NetworkAccessManager::NetworkAccessManager(QNetworkAccessManager *manager, QObject *parent)

: QNetworkAccessManager(parent)

{

setCache(manager->cache());
setCookieJar(manager->cookieJar());
setProxy(manager->proxy());
setProxyFactory(manager->proxyFactory());

}