[PyQt] QtWebKit and QtWebKitWidgets

Florian Bruhin me at the-compiler.org
Mon Sep 15 10:03:04 BST 2014


* Gianluca Romanin <romaninz at gmail.com> [2014-09-15 10:36:50 +0200]:
> I'm using the Qt widget style to build a little Webkit browser.
> I need some Html5 features and I would like to know what version of Webkit
> I'm currently using.
> How I can do it? I can't find lot of infos about the Webkit version used by
> Qt.

You can do this:

    from PyQt5.QtWebKit import qWebKitVersion
    print(qWebKitVersion())

For me it's 538.1 with Qt 5.3.1.

Also note QtWebKit will be deprecated eventually:

http://blog.qt.digia.com/blog/2014/09/08/qt-5-4-alpha-available/

Maybe it would make more sense for you to wait some more weeks for
Qt5.4 and (hopefully) PyQt bindings for QtWebEngine, and then use
that?

Though I think it'll be some more months or even years before QtWebKit
is fully deprecated, but that's only a guess.

> It is not clear to me what are the differences between QtWebKit and
> QtWebKitWidgets.

In QtWebKit there are some WebKit related modules which aren't widgets.
Basically the same thing like QtCore and QtWidgets.

    >>> for e in dir(QtWebKit):
    ...     if not e.startswith('__'):
    ...         print(e)
    ...
    QWebDatabase
    QWebElement
    QWebElementCollection
    QWebHistory
    QWebHistoryInterface
    QWebHistoryItem
    QWebPluginFactory
    QWebSecurityOrigin
    QWebSettings
    qWebKitMajorVersion
    qWebKitMinorVersion
    qWebKitVersion

> It seems that QtWebKit is used mainly for QML and that wraps a more recent
> version of Webkit: QtWebKit dll is about 18 MB while QtWebKitWidgets dll is
> not even 1MB. If so, how can I use QtWebKit in a QWidget style application
> without QML? Is it possible?

Yes, by importing QtWebKitWidgets instead ;)

A minimal example showing a webpage:

    import sys

    from PyQt5.QtCore import QUrl
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebKitWidgets import QWebView

    app = QApplication(sys.argv)
    wv = QWebView()
    wv.load(QUrl(sys.argv[1]))
    wv.show()
    app.exec_()

By the way: Depending on what you're building exactly, it might make
more sense to join an existing project:

- I'm building a vim-like browser using PyQt and QtWebKit, see
  https://github.com/The-Compiler/qutebrowser

  I'd love some contributors, and I'm happy to mentor and help people
  along the way.

- Detlev Offenbach is working on the eric IDE[1] which has an
  integrated very feature-complete browser, and he told me he's
  interested in people helping out with it, and also with turning it
  into a standalone application. I think he's reading here as well.

[1] http://eric-ide.python-projects.org/

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
             GPG 0xFD55A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140915/43508dd9/attachment.sig>


More information about the PyQt mailing list