Home · All Classes · Modules

QGraphicsWebView Class Reference
[QtWebKit module]

The QGraphicsWebView class allows Web content to be added to a GraphicsView. More...

Inherits QGraphicsWidget.

Methods

Qt Signals


Detailed Description

The QGraphicsWebView class allows Web content to be added to a GraphicsView.

An instance of this class renders Web content from a URL or supplied as data, using features of the QtWebKit module.

If the width and height of the item are not set, they will default to 800 and 600, respectively. If the Web page contents is larger than that, scrollbars will be shown if not disabled explicitly.

Browser Features

Many of the functions, signals and properties provided by QWebView are also available for this item, making it simple to adapt existing code to use QGraphicsWebView instead of QWebView.

The item uses a QWebPage object to perform the rendering of Web content, and this can be obtained with the page() function, enabling the document itself to be accessed and modified.

As with QWebView, the item records the browsing history using a QWebHistory object, accessible using the history() function. The QWebSettings object that defines the configuration of the browser can be obtained with the settings() function, enabling features like plugin support to be customized for each item.


Method Documentation

QGraphicsWebView.__init__ (self, QGraphicsItem parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an empty QGraphicsWebView with parent parent.

See also load().

QGraphicsWebView.back (self)

This method is also a Qt slot with the C++ signature void back().

Convenience slot that loads the previous document in the list of documents built by navigating links. Does nothing if there is no previous document.

See also forward().

QGraphicsWebView.contextMenuEvent (self, QGraphicsSceneContextMenuEvent)

Reimplemented from QGraphicsItem.contextMenuEvent().

QGraphicsWebView.dragEnterEvent (self, QGraphicsSceneDragDropEvent)

Reimplemented from QGraphicsItem.dragEnterEvent().

QGraphicsWebView.dragLeaveEvent (self, QGraphicsSceneDragDropEvent)

Reimplemented from QGraphicsItem.dragLeaveEvent().

QGraphicsWebView.dragMoveEvent (self, QGraphicsSceneDragDropEvent)

Reimplemented from QGraphicsItem.dragMoveEvent().

QGraphicsWebView.dropEvent (self, QGraphicsSceneDragDropEvent)

Reimplemented from QGraphicsItem.dropEvent().

bool QGraphicsWebView.event (self, QEvent)

Reimplemented from QObject.event().

bool QGraphicsWebView.findText (self, QString subString, QWebPage.FindFlags options = 0)

Finds the specified string, subString, in the page, using the given options.

If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences that exist in the page. All subsequent calls will extend the highlight, rather than replace it, with occurrences of the new string.

If the HighlightAllOccurrences flag is not passed, the function will select an occurrence and all subsequent calls will replace the current occurrence with the next one.

To clear the selection, just pass an empty string.

Returns true if subString was found; otherwise returns false.

See also QWebPage.selectedText() and QWebPage.selectionChanged().

QGraphicsWebView.focusInEvent (self, QFocusEvent)

Reimplemented from QGraphicsItem.focusInEvent().

bool QGraphicsWebView.focusNextPrevChild (self, bool next)

Reimplemented from QGraphicsWidget.focusNextPrevChild().

QGraphicsWebView.focusOutEvent (self, QFocusEvent)

Reimplemented from QGraphicsItem.focusOutEvent().

QGraphicsWebView.forward (self)

This method is also a Qt slot with the C++ signature void forward().

Convenience slot that loads the next document in the list of documents built by navigating links. Does nothing if there is no next document.

See also back().

QWebHistory QGraphicsWebView.history (self)

Returns a pointer to the view's history of navigated web pages.

It is equivalent to

     view->page()->history();

QGraphicsWebView.hoverLeaveEvent (self, QGraphicsSceneHoverEvent)

Reimplemented from QGraphicsItem.hoverLeaveEvent().

QGraphicsWebView.hoverMoveEvent (self, QGraphicsSceneHoverEvent)

Reimplemented from QGraphicsItem.hoverMoveEvent().

QIcon QGraphicsWebView.icon (self)

QGraphicsWebView.inputMethodEvent (self, QInputMethodEvent)

Reimplemented from QGraphicsItem.inputMethodEvent().

QVariant QGraphicsWebView.inputMethodQuery (self, Qt.InputMethodQuery query)

Reimplemented from QGraphicsItem.inputMethodQuery().

bool QGraphicsWebView.isModified (self)

bool QGraphicsWebView.isTiledBackingStoreFrozen (self)

QVariant QGraphicsWebView.itemChange (self, QGraphicsItem.GraphicsItemChange change, QVariant value)

Reimplemented from QGraphicsItem.itemChange().

QGraphicsWebView.keyPressEvent (self, QKeyEvent)

Reimplemented from QGraphicsItem.keyPressEvent().

QGraphicsWebView.keyReleaseEvent (self, QKeyEvent)

Reimplemented from QGraphicsItem.keyReleaseEvent().

QGraphicsWebView.load (self, QUrl url)

Loads the specified url and displays it.

Note: The view remains the same until enough data has arrived to display the new url.

See also setUrl(), url(), and urlChanged().

QGraphicsWebView.load (self, QNetworkRequest request, QNetworkAccessManager.Operation operation = QNetworkAccessManager.GetOperation, QByteArray body = QByteArray())

Loads a network request, request, using the method specified in operation.

body is optional and is only used for POST operations.

Note: The view remains the same until enough data has arrived to display the new url.

See also url() and urlChanged().

QGraphicsWebView.mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent)

Reimplemented from QGraphicsItem.mouseDoubleClickEvent().

QGraphicsWebView.mouseMoveEvent (self, QGraphicsSceneMouseEvent)

Reimplemented from QGraphicsItem.mouseMoveEvent().

QGraphicsWebView.mousePressEvent (self, QGraphicsSceneMouseEvent)

Reimplemented from QGraphicsItem.mousePressEvent().

QGraphicsWebView.mouseReleaseEvent (self, QGraphicsSceneMouseEvent)

Reimplemented from QGraphicsItem.mouseReleaseEvent().

QWebPage QGraphicsWebView.page (self)

Returns a pointer to the underlying web page.

See also setPage().

QAction QGraphicsWebView.pageAction (self, QWebPage.WebAction action)

Returns a pointer to a QAction that encapsulates the specified web action action.

QGraphicsWebView.paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget = None)

Reimplemented from QGraphicsItem.paint().

QGraphicsWebView.reload (self)

This method is also a Qt slot with the C++ signature void reload().

Reloads the current document.

See also stop() and loadStarted().

QPainter.RenderHints QGraphicsWebView.renderHints (self)

bool QGraphicsWebView.resizesToContents (self)

bool QGraphicsWebView.sceneEvent (self, QEvent)

Reimplemented from QGraphicsItem.sceneEvent().

QGraphicsWebView.setContent (self, QByteArray data, QString mimeType = '', QUrl baseUrl = QUrl())

Sets the content of the web graphicsitem to the specified content data. If the mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.

External objects referenced in the content are located relative to baseUrl.

The data is loaded immediately; external objects are loaded asynchronously.

See also load(), setHtml(), and QWebFrame.toHtml().

QGraphicsWebView.setGeometry (self, QRectF rect)

Reimplemented from QGraphicsLayoutItem.setGeometry().

QGraphicsWebView.setHtml (self, QString html, QUrl baseUrl = QUrl())

Sets the content of the web view to the specified html.

External objects such as stylesheets or images referenced in the HTML document are located relative to baseUrl.

The html is loaded immediately; external objects are loaded asynchronously.

When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. Alternatively, the encoding can also be specified by the web server.

This is a convenience function equivalent to setContent(html, "text/html", baseUrl).

Warning: This function works only for HTML, for other mime types (i.e. XHTML, SVG) setContent() should be used instead.

See also load(), setContent(), QWebFrame.toHtml(), and QWebFrame.setContent().

QGraphicsWebView.setPage (self, QWebPage)

Makes page the new web page of the web graphicsitem.

The parent QObject of the provided page remains the owner of the object. If the current document is a child of the web view, it will be deleted.

See also page().

QGraphicsWebView.setRenderHint (self, QPainter.RenderHint hint, bool enabled = True)

If enabled is true, enables the specified render hint; otherwise disables it.

This function was introduced in Qt 4.8.

See also renderHints and QPainter.renderHints().

QGraphicsWebView.setRenderHints (self, QPainter.RenderHints hints)

QGraphicsWebView.setResizesToContents (self, bool enabled)

QGraphicsWebView.setTiledBackingStoreFrozen (self, bool frozen)

QWebSettings QGraphicsWebView.settings (self)

Returns a pointer to the view/page specific settings object.

It is equivalent to

     view->page()->settings();

See also QWebSettings.globalSettings().

QGraphicsWebView.setUrl (self, QUrl)

QGraphicsWebView.setZoomFactor (self, float)

QSizeF QGraphicsWebView.sizeHint (self, Qt.SizeHint which, QSizeF constraint)

Reimplemented from QGraphicsLayoutItem.sizeHint().

QGraphicsWebView.stop (self)

This method is also a Qt slot with the C++ signature void stop().

Convenience slot that stops loading the document.

See also reload() and loadFinished().

QString QGraphicsWebView.title (self)

QGraphicsWebView.triggerPageAction (self, QWebPage.WebAction action, bool checked = False)

Triggers the specified action. If it is a checkable action the specified checked state is assumed.

See also pageAction().

QGraphicsWebView.updateGeometry (self)

Reimplemented from QGraphicsLayoutItem.updateGeometry().

QUrl QGraphicsWebView.url (self)

QGraphicsWebView.wheelEvent (self, QGraphicsSceneWheelEvent)

Reimplemented from QGraphicsItem.wheelEvent().

float QGraphicsWebView.zoomFactor (self)


Qt Signal Documentation

void iconChanged ()

This is the default overload of this signal.

This signal is emitted whenever the icon of the page is loaded or changes.

In order for icons to be loaded, you will need to set an icon database path using QWebSettings.setIconDatabasePath().

See also icon() and QWebSettings.setIconDatabasePath().

void linkClicked (const ::QUrl&)

This is the default overload of this signal.

This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy property is set to delegate the link handling for the specified url.

See also QWebPage.linkDelegationPolicy().

void loadFinished (bool)

This is the default overload of this signal.

This signal is emitted when a load of the page is finished. ok will indicate whether the load was successful or any error occurred.

See also loadStarted().

void loadProgress (int)

This is the default overload of this signal.

This signal is emitted every time an element in the web page completes loading and the overall loading progress advances.

This signal tracks the progress of all child frames.

The current value is provided by progress and scales from 0 to 100, which is the default range of QProgressBar.

See also loadStarted() and loadFinished().

void loadStarted ()

This is the default overload of this signal.

This signal is emitted when a new load of the page is started.

See also loadProgress() and loadFinished().

void statusBarMessage (const QString&)

This is the default overload of this signal.

This signal is emitted when the statusbar text is changed by the page.

void titleChanged (const QString&)

This is the default overload of this signal.

This signal is emitted whenever the title of the main frame changes.

See also title().

void urlChanged (const ::QUrl&)

This is the default overload of this signal.

This signal is emitted when the url of the view changes.

See also url() and load().


PyQt 4.12.1 for X11Copyright © Riverbank Computing Ltd and The Qt Company 2015Qt 4.8.7