4. Components of WebKit
CSS
DOM SVG
HTML Canvas
WebCore
Rendering
JavaScriptCore
Worker Storage
WebKit Library Sockets
5. Different Ports
WebCore Graphics
Graphics
Context
Chromium Gtk
Mac Qt
Skia Cairo
Core Graphics QtPainter
Graphics
Stack
6. QtWebKit
A bridge between Qt and WebKit
With QtWebKit you can:
● (easily!) embed a fully
functional, standard
compliant, web browser
inside your application
● inspect/extract the
content
● manipulate the web page
● integrate your application
with web services
7. QtWebKit (main) modules
QWebView
a QWidget (your browser window/tab)
QWebPage
a browsing session: settings + history + plugin +
network + user interaction + document
QWebFrame
the document, one QWebFrame per html page or
svg document.
can have additional child frame (one per
<frame>)
magic happens here (qt ↔ page interaction)
8. QWebView
QWebView is your “browser”
QWebView is a QWidget
QWebView exposes high-level signals/slots
load() / reload() / stop()
back() / forward()
linkClicked() / loadProgress() /
statusBarMessage()
QWebView signals/slots are an excerpt of QWebPage +
QWebFrame
9. QWebPage
QWebPage is not a QWidget
but a QApplication is still required
QWebPage is the browsing ecosystem
history + settings + plugins + network +
document
Interact with the document via the PageAction
10. QWebFrame
QWebFrame is not a QWidget
QWebFrame is a frame inside a web page
each QWebPage object has at least one frame
plus one QWebFrame for every <frame />
14. Qt & JavaScript
eval javascript code inside the frame context
QWebFrame::evaluateJavaScript
inject a QObject into the frame context
15. Exposing to the World
Object Instance
From Qt/C++ to Javascript
Variable name
Visible from JavaScript
QWebFrame::addToJavaScriptWindowObject(QString, QObject *)
Exported
Public Slots
QWebView w;
w.page()->mainFrame() Public Properties
Signals
16. Exposing to the World
class Dialog : public QDialog {
Q_OBJECT Public Slots
public:
Public Properties
Dialog (QObject *parent = 0); Signals
public slots:
void showMessage (const QString& message);
};
QWebView webView;
QWebFrame *frame = webView.page()->mainFrame();
frame->addToJavaScriptWindowObject(“dialog”, new Dialog);
17. Exposing to the World
page()->mainFrame()->addToJavaScriptWindowObject(“dialog”, new Dialog);
<input type=”button” value=”Click Me!”
onClick=”dialog.showMessage(‘You clicked me!’)”>
Public Slot
Instance of
Dialog Object
18. Signal & Slot
Javascript
Signal Slot
foobar.modified.connect(doSomething)
QObject JavaScript
Instance Function
24. Hybrid Applications Qt + WebKit
You can inject a QObject
Call Public Slots
Set/Get Public Properties
Connect a signal to a javascript function
Or you can extract from the frame context a function
and call it from the C++ side.
http://src.develer.com/gitweb/pub/users/th30z/qtday/.git
git clone git://src.develer.com/users/th30z/qtday/.git
25. Questions?
Hybrid development
using Qt WebKit
http://src.develer.com/gitweb/pub/users/th30z/qtday/.git
git clone git://src.develer.com/users/th30z/qtday/.git
25