summaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/webkitsnippets
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-03 18:56:26 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-03-03 18:56:26 -0300
commitca81d9a32c6d31ed86dd3723ee4c17c6d5b602a9 (patch)
tree89c1ab27a4990462025d9ce65c56e771e92ae8c9 /doc/codesnippets/webkitsnippets
parent094de675913e82ea11219d0262d72127319c4f29 (diff)
downloadpyside-ca81d9a32c6d31ed86dd3723ee4c17c6d5b602a9.tar.gz
pyside-ca81d9a32c6d31ed86dd3723ee4c17c6d5b602a9.tar.xz
pyside-ca81d9a32c6d31ed86dd3723ee4c17c6d5b602a9.zip
More code snippets ported to Python.
Diffstat (limited to 'doc/codesnippets/webkitsnippets')
-rw-r--r--doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp11
-rw-r--r--doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp31
-rw-r--r--doc/codesnippets/webkitsnippets/webpage/main.cpp33
3 files changed, 75 insertions, 0 deletions
diff --git a/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp b/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
new file mode 100644
index 0000000..c8245b6
--- /dev/null
+++ b/doc/codesnippets/webkitsnippets/qtwebkit_qwebinspector_snippet.cpp
@@ -0,0 +1,11 @@
+
+def wrapInFunction():
+//! [0]
+ # ...
+ page = QWebPage()
+ # ...
+
+ inspector = QWebInspector()
+ inspector.setPage(page)
+//! [0]
+
diff --git a/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp b/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp
new file mode 100644
index 0000000..19a6835
--- /dev/null
+++ b/doc/codesnippets/webkitsnippets/qtwebkit_qwebview_snippet.cpp
@@ -0,0 +1,31 @@
+
+def wrapInFunction():
+//! [0]
+ view.page().history()
+//! [0]
+
+
+//! [1]
+ view.page().settings()
+//! [1]
+
+
+//! [2]
+ view.triggerAction(QWebPage.Copy)
+//! [2]
+
+
+//! [3]
+ view.page().triggerPageAction(QWebPage.Stop)
+//! [3]
+
+
+//! [4]
+ view.page().triggerPageAction(QWebPage.GoBack)
+//! [4]
+
+
+//! [5]
+ view.page().triggerPageAction(QWebPage.GoForward)
+//! [5]
+
diff --git a/doc/codesnippets/webkitsnippets/webpage/main.cpp b/doc/codesnippets/webkitsnippets/webpage/main.cpp
new file mode 100644
index 0000000..4fa1949
--- /dev/null
+++ b/doc/codesnippets/webkitsnippets/webpage/main.cpp
@@ -0,0 +1,33 @@
+//! [0]
+class Thumbnailer (QObject):
+ def __init__(self, url):
+//! [1]
+ QObject.__init__(self)
+ self.page = QWebPage()
+ self.page.mainFrame().load(url)
+ page.loadFinished[bool].connect(self.render)
+//! [1]
+
+ finished = Signal()
+
+//! [2]
+ def render(self):
+ self.page.setViewportSize(self.page.mainFrame().contentsSize())
+ image = QImage(self.page.viewportSize(), QImage.Format_ARGB32)
+ painter = QPainter(image)
+
+ self.page.mainFrame().render(painter)
+ painter.end()
+
+ thumbnail = image.scaled(400, 400)
+ thumbnail.save("thumbnail.png")
+
+ self.finished.emit()
+//! [2]
+//! [0]
+
+app = QApplication(sys.argv)
+
+thumbnail = Thumbnailer(QUrl("http://qt.nokia.com"))
+thumbnail.finished.connect(app.quit)
+sys.exit(app.exec_())