KDE 4.9 PyKDE API Reference

- KDE's Python API

# WebView Class Reference

`from PyKDE4.plasma import *`

Inherits: QGraphicsWidget → QObject
Namespace: Plasma

## Detailed Description

WebView plasma/widgets/webview.h <Plasma/Widgets/WebView>

Provides a widget to display html content in Plasma.

## Signals

| loadFinished (bool success)
| loadProgress (int percent)
| urlChanged (QUrl url)

## Methods

| __init__ (self, QGraphicsItem parent=0)
| back (self)
QSizeF | contentsSize (self)
| contextMenuEvent (self, QGraphicsSceneContextMenuEvent event)
| dragEnterEvent (self, QGraphicsSceneDragDropEvent event)
| dragLeaveEvent (self, QGraphicsSceneDragDropEvent event)
| dragMoveEvent (self, QGraphicsSceneDragDropEvent event)
bool | dragToScroll (self)
| dropEvent (self, QGraphicsSceneDragDropEvent event)
| focusInEvent (self, QFocusEvent event)
| focusOutEvent (self, QFocusEvent event)
| forward (self)
QRectF | geometry (self)
| hoverMoveEvent (self, QGraphicsSceneHoverEvent event)
QString | html (self)
QVariant | itemChange (self, QGraphicsItem::GraphicsItemChange change, QVariant value)
| keyPressEvent (self, QKeyEvent event)
| keyReleaseEvent (self, QKeyEvent event)
QWebFrame | mainFrame (self)
| mouseDoubleClickEvent (self, QGraphicsSceneMouseEvent event)
| mouseMoveEvent (self, QGraphicsSceneMouseEvent event)
| mousePressEvent (self, QGraphicsSceneMouseEvent event)
| mouseReleaseEvent (self, QGraphicsSceneMouseEvent event)
QWebPage | page (self)
| paint (self, QPainter painter, QStyleOptionGraphicsItem option, QWidget widget=0)
| reload (self)
QPointF | scrollPosition (self)
| setDragToScroll (self, bool drag)
| setGeometry (self, QRectF geometry)
| setHtml (self, QString html, KUrl baseUrl=KUrl())
| setPage (self, QWebPage page)
| setScrollPosition (self, QPointF position)
| setUrl (self, KUrl url)
| setZoomFactor (self, float zoom)
QSizeF | sizeHint (self, Qt::SizeHint which, QSizeF constraint)
| stop (self)
KUrl | url (self)
QRectF | viewportGeometry (self)
| wheelEvent (self, QGraphicsSceneWheelEvent event)
float | zoomFactor (self)

## Signal Documentation

loadFinished | ( | bool | success
| ) |  |  |

This signal is emitted when loading is completed.

Parameters:

  | success | true if the content was loaded successfully, otherwise false

Signal syntax:
  `QObject.connect(source, SIGNAL("loadFinished(bool)"), target_slot)`

loadProgress | ( | int | percent
| ) |  |  |

During loading progress, this signal is emitted. The values are always between 0 and 100, inclusive.

Parameters:

  | percent | the estimated amount the loading is complete

Signal syntax:
  `QObject.connect(source, SIGNAL("loadProgress(int)"), target_slot)`

urlChanged | ( | QUrl | url
| ) |  |  |

url displayed by the web page changed

Since:
  4.6

Signal syntax:
  `QObject.connect(source, SIGNAL("urlChanged(const QUrl&)"), target_slot)`

## Method Documentation

__init__ | ( | self, |
|  | QGraphicsItem | parent=0
| ) |  |  |

back | ( |  | self ) |

Loads the previous document in the list of documents built by navigating links.

Since:
  4.6

QSizeF contentsSize | ( |  | self ) |

Returns:
  the size of the internal widget

Since:
  4.4

contextMenuEvent | ( | self, |
|  | QGraphicsSceneContextMenuEvent | event
| ) |  |  |

dragEnterEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

dragLeaveEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

dragMoveEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

bool dragToScroll | ( |  | self ) |

Returns:
  true if the page can be scrolled by dragging the mouse

Since:
  4.3

dropEvent | ( | self, |
|  | QGraphicsSceneDragDropEvent | event
| ) |  |  |

focusInEvent | ( | self, |
|  | QFocusEvent | event
| ) |  |  |

focusOutEvent | ( | self, |
|  | QFocusEvent | event
| ) |  |  |

forward | ( |  | self ) |

Loads the next document in the list of documents built by navigating links.

Since:
  4.6

QRectF geometry | ( |  | self ) |

Reimplementation

hoverMoveEvent | ( | self, |
|  | QGraphicsSceneHoverEvent | event
| ) |  |  |

QString html | ( |  | self ) |

Returns:
  the html content of the page

QVariant itemChange | ( | self, |
|  | QGraphicsItem::GraphicsItemChange | change,
|  | QVariant | value
| ) |  |  |

keyPressEvent | ( | self, |
|  | QKeyEvent | event
| ) |  |  |

keyReleaseEvent | ( | self, |
|  | QKeyEvent | event
| ) |  |  |

QWebFrame mainFrame | ( |  | self ) |

The main web frame associated with this item.

mouseDoubleClickEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mouseMoveEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mousePressEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

mouseReleaseEvent | ( | self, |
|  | QGraphicsSceneMouseEvent | event
| ) |  |  |

QWebPage page | ( |  | self ) |

The QWebPage associated with this item. Useful when more of the features of the full QWebPage object need to be accessed.

paint | ( | self, |
|  | QPainter | painter,
|  | QStyleOptionGraphicsItem | option,
|  | QWidget | widget=0
| ) |  |  |

Reimplementation

reload | ( |  | self ) |

Reloads the current document.

Since:
  4.6

QPointF scrollPosition | ( |  | self ) |

Returns:
  the position of the webpage relative to this widget

Since:
  4.4

setDragToScroll | ( | self, |
|  | bool | drag
| ) |  |  |

Sets if the page can be scrolled around by dragging the contents with the mouse

Since:
  4.3

setGeometry | ( | self, |
|  | QRectF | geometry
| ) |  |  |

Reimplementation

setHtml | ( | self, |
|  | QString | html,
|  | KUrl | baseUrl=KUrl()
| ) |  |  |

Sets the html to be shown along with a base URL to be used to resolve relative references.

Parameters:

  | html | the html (in utf8) to display in the content area
  | baseUrl | the base url for relative references

setPage | ( | self, |
|  | QWebPage | page
| ) |  |  |

Sets the page to use in this item. The owner of the webpage remains, however if this WebView object is the owner of the current page, then the current page is deleted

Parameters:

  | page | the page to set in this view

setScrollPosition | ( | self, |
|  | QPointF | position
| ) |  |  |

Sets the position of the webpage relative to this widget

Since:
  4.4

setUrl | ( | self, |
|  | KUrl | url
| ) |  |  |

Sets the URL to display. Loading may happen asynchronously.

Parameters:

  | url | the location of the content to load.

setZoomFactor | ( | self, |
|  | float | zoom
| ) |  |  |

Sets the zoom factor of the page

Since:
  4.4

QSizeF sizeHint | ( | self, |
|  | Qt::SizeHint | which,
|  | QSizeF | constraint
| ) |  |  |

stop | ( |  | self ) |

Stops loading the document.

Since:
  4.6

KUrl url | ( |  | self ) |

Returns:
  the html content of the page

QRectF viewportGeometry | ( |  | self ) |

The geometry of the area that actually displays the web page

Since:
  4.4

wheelEvent | ( | self, |
|  | QGraphicsSceneWheelEvent | event
| ) |  |  |

float zoomFactor | ( |  | self ) |

The zoom factor of the page

Since:
  4.4