Extending Qt WebKit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Estenent QtWebKit|Catalan]] [[Extendiendo QtWebKit|Spanish]] [http://qt-devnet.developpez.com/tutoriels/qtwebkit/etendre-webkit/ French] ''[qt-devnet.developpez.com]'' [[Extending Qt WebKit Japanese|日本語]]
[[Category:Developing with Qt::QtWebKit]]<br />[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]


=Extending Qt WebKit=
'''English''' [[Estenent_QtWebKit|Catalan]] [[Extendiendo_QtWebKit|Spanish]] &quot;French&amp;quot;:http://qt-devnet.developpez.com/tutoriels/qtwebkit/etendre-webkit/ [[Extending_Qt_WebKit_Japanese|日本語]]
 
= 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.
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 [http://doc.qt.nokia.com/qq/index.html Qt Quarterly] ''[doc.qt.nokia.com]'' provide a good introduction to the technologies and processes involved.
A series of articles from &quot;Qt Quarterly&amp;quot;:http://doc.qt.nokia.com/qq/index.html provide a good introduction to the technologies and processes involved.


==Build network interfaces==
== Build network interfaces ==


Hybrid designs often require some custom Qt code to handle network interactions. [http://doc.qt.nokia.com/qq/qq23-web-service.html Using a Simple Web Service with Qt] ''[doc.qt.nokia.com]'' uses the [http://www.mathtran.org/ MathTran] ''[mathtran.org]'' 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.
Hybrid designs often require some custom Qt code to handle network interactions. &quot;Using a Simple Web Service with Qt &quot;:http://doc.qt.nokia.com/qq/qq23-web-service.html uses the &quot;MathTran&amp;quot;:http://www.mathtran.org/ 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==
== Add Qt widgets to Web-centric user interfaces ==


David Boddie’s [http://doc.qt.nokia.com/qq/qq26-webplugin.html Plugging into the Web] ''[doc.qt.nokia.com]'' 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:
David Boddie's &quot;Plugging into the Web&amp;quot;:http://doc.qt.nokia.com/qq/qq26-webplugin.html 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:
 
<code> int main(int argc, char *argv[])<br /> {<br /> QApplication app(argc, argv);<br /> QWebView view;<br /> view.load(QUrl(&quot;http://www.trolltech.com/&amp;quot;));<br /> view.show();<br /> return app.exec&amp;amp;#40;&amp;#41;;<br /> }<br /></code>


and goes on to show how to use QWebPluginFactory to create a simple widget to display comma-separated-variable files.
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==
== Adding New Protocols to QtWebKit ==
 
David’s follow-on [http://doc.qt.nokia.com/qq/32/qq32-webkit-protocols.html Adding New Protocols to QtWebKit] ''[doc.qt.nokia.com]'' uses of Qt’s network access <span class="caps">API</span> with WebKit to turn QWebView into a simple <span class="caps">FTP</span> client. Qt’s network access <span class="caps">API</span> 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 <span class="caps">API</span> 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 <span class="caps">FTP</span> 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.
David's follow-on &quot;Adding New Protocols to QtWebKit&amp;quot;:http://doc.qt.nokia.com/qq/32/qq32-webkit-protocols.html 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.


Here’s how he replaces an existing network manager for a QWebPage by subclassing QNetworkAccessManager and reimplementing its createRequest() function to check for <span class="caps">URL</span>s with the ftp scheme.
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.


===Categories:===
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.


* [[:Category:Developing with Qt|Developing_with_Qt]]
<code><br />NetworkAccessManager::NetworkAccessManager(QNetworkAccessManager *manager, QObject *parent)<br /> : QNetworkAccessManager(parent)<br />{<br /> setCache(manager-&gt;cache());<br /> setCookieJar(manager-&gt;cookieJar());<br /> setProxy(manager-&gt;proxy());<br /> setProxyFactory(manager-&gt;proxyFactory());<br />}
** [[:Category:Developing with Qt::QtWebKit|QtWebKit]]

Revision as of 10:09, 24 February 2015


[toc align_right="yes&quot; depth="2&quot;]

English Catalan Spanish "French&quot;:http://qt-devnet.developpez.com/tutoriels/qtwebkit/etendre-webkit/ 日本語

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&quot;:http://doc.qt.nokia.com/qq/index.html 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 ":http://doc.qt.nokia.com/qq/qq23-web-service.html uses the "MathTran&quot;:http://www.mathtran.org/ 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&quot;:http://doc.qt.nokia.com/qq/qq26-webplugin.html 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[])<br /> {<br /> QApplication app(argc, argv);<br /> QWebView view;<br /> view.load(QUrl(&quot;http://www.trolltech.com/&amp;quot;));<br /> view.show();<br /> return app.exec&amp;amp;#40;&amp;#41;;<br /> }<br />

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&quot;:http://doc.qt.nokia.com/qq/32/qq32-webkit-protocols.html 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());
}