Home · All Classes · All Functions · Overviews

QGraphicsWebView Class Reference
[
QtWebKit module]

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

 #include <QGraphicsWebView>

This class is not part of the Qt GUI Framework Edition.

Inherits QGraphicsWidget.

This class was introduced in Qt 4.6.


Properties


Public Functions

QGraphicsWebView ( QGraphicsItem * parent = 0 )
~QGraphicsWebView ()
bool findText ( const QString & subString, QWebPage::FindFlags options = 0 )
QWebHistory * history () const
QIcon icon () const
bool isModified () const
void load ( const QUrl & url )
void load ( const QNetworkRequest & request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )
QWebPage * page () const
QAction * pageAction ( QWebPage::WebAction action ) const
void setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )
void setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )
void setPage ( QWebPage * page )
void setUrl ( const QUrl & )
void setZoomFactor ( qreal )
QWebSettings * settings () const
QString title () const
void triggerPageAction ( QWebPage::WebAction action, bool checked = false )
QUrl url () const
qreal zoomFactor () const

Reimplemented Public Functions

virtual bool event ( QEvent * event )
virtual QVariant inputMethodQuery ( Qt::InputMethodQuery query ) const
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant & value )
virtual void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )
virtual void setGeometry ( const QRectF & rect )
virtual QSizeF sizeHint ( Qt::SizeHint which, const QSizeF & constraint ) const
virtual void updateGeometry ()

Public Slots

void back ()
void forward ()
void reload ()
void stop ()

Signals

void iconChanged ()
void linkClicked ( const QUrl & url )
void loadFinished ( bool ok )
void loadProgress ( int progress )
void loadStarted ()
void statusBarMessage ( const QString & text )
void titleChanged ( const QString & title )
void urlChanged ( const QUrl & url )

Reimplemented Protected Functions

virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * ev )
virtual void dragEnterEvent ( QGraphicsSceneDragDropEvent * ev )
virtual void dragLeaveEvent ( QGraphicsSceneDragDropEvent * ev )
virtual void dragMoveEvent ( QGraphicsSceneDragDropEvent * ev )
virtual void dropEvent ( QGraphicsSceneDragDropEvent * ev )
virtual void focusInEvent ( QFocusEvent * ev )
virtual bool focusNextPrevChild ( bool next )
virtual void focusOutEvent ( QFocusEvent * ev )
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * ev )
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * ev )
virtual void inputMethodEvent ( QInputMethodEvent * ev )
virtual void keyPressEvent ( QKeyEvent * ev )
virtual void keyReleaseEvent ( QKeyEvent * ev )
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * ev )
virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * ev )
virtual void mousePressEvent ( QGraphicsSceneMouseEvent * ev )
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * ev )
virtual bool sceneEvent ( QEvent * event )
virtual void wheelEvent ( QGraphicsSceneWheelEvent * ev )

Additional Inherited Members


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.

See also QWebView and QGraphicsTextItem.


Property Documentation

icon : const QIcon

This property holds the icon associated with the web page currently viewed.

By default, this property contains a null icon.

Access functions:

QIcon icon () const

Notifier signal:

void iconChanged ()

See also iconChanged() and QWebSettings::iconForUrl().

modified : const bool

This property holds whether the document was modified by the user.

Parts of HTML documents can be editable for example through the contenteditable attribute on HTML elements.

By default, this property is false.

Access functions:

bool isModified () const

title : const QString

This property holds the title of the web page currently viewed.

By default, this property contains an empty string.

Access functions:

QString title () const

Notifier signal:

void titleChanged ( const QString & title )

See also titleChanged().

url : QUrl

This property holds the url of the web page currently viewed.

Setting this property clears the view and loads the URL.

By default, this property contains an empty, invalid URL.

Access functions:

QUrl url () const
void setUrl ( const QUrl & )

Notifier signal:

void urlChanged ( const QUrl & url )

See also load() and urlChanged().

zoomFactor : qreal

This property holds the zoom factor for the view.

This property was introduced in Qt 4.5.

Access functions:

qreal zoomFactor () const
void setZoomFactor ( qreal )

Member Function Documentation

QGraphicsWebView::QGraphicsWebView ( QGraphicsItem * parent = 0 )

Constructs an empty QGraphicsWebView with parent parent.

See also load().

QGraphicsWebView::~QGraphicsWebView ()

Destroys the item.

void QGraphicsWebView::back ()   [slot]

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().

void QGraphicsWebView::contextMenuEvent ( QGraphicsSceneContextMenuEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::contextMenuEvent().

void QGraphicsWebView::dragEnterEvent ( QGraphicsSceneDragDropEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::dragEnterEvent().

void QGraphicsWebView::dragLeaveEvent ( QGraphicsSceneDragDropEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::dragLeaveEvent().

void QGraphicsWebView::dragMoveEvent ( QGraphicsSceneDragDropEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::dragMoveEvent().

void QGraphicsWebView::dropEvent ( QGraphicsSceneDragDropEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::dropEvent().

bool QGraphicsWebView::event ( QEvent * event )   [virtual]

Reimplemented from QObject::event().

bool QGraphicsWebView::findText ( const 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().

void QGraphicsWebView::focusInEvent ( QFocusEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::focusInEvent().

bool QGraphicsWebView::focusNextPrevChild ( bool next )   [virtual protected]

Reimplemented from QGraphicsWidget::focusNextPrevChild().

void QGraphicsWebView::focusOutEvent ( QFocusEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::focusOutEvent().

void QGraphicsWebView::forward ()   [slot]

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 () const

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

It is equivalent to

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

void QGraphicsWebView::hoverLeaveEvent ( QGraphicsSceneHoverEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::hoverLeaveEvent().

void QGraphicsWebView::hoverMoveEvent ( QGraphicsSceneHoverEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::hoverMoveEvent().

void QGraphicsWebView::iconChanged ()   [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 QGraphicsWebView::inputMethodEvent ( QInputMethodEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::inputMethodEvent().

QVariant QGraphicsWebView::inputMethodQuery ( Qt::InputMethodQuery query ) const   [virtual]

Reimplemented from QGraphicsItem::inputMethodQuery().

QVariant QGraphicsWebView::itemChange ( GraphicsItemChange change, const QVariant & value )   [virtual]

Reimplemented from QGraphicsItem::itemChange().

void QGraphicsWebView::keyPressEvent ( QKeyEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::keyPressEvent().

void QGraphicsWebView::keyReleaseEvent ( QKeyEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::keyReleaseEvent().

void QGraphicsWebView::linkClicked ( const QUrl & url )   [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 QGraphicsWebView::load ( const 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().

void QGraphicsWebView::load ( const QNetworkRequest & request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const 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().

void QGraphicsWebView::loadFinished ( bool ok )   [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 QGraphicsWebView::loadProgress ( int progress )   [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 QGraphicsWebView::loadStarted ()   [signal]

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

See also loadProgress() and loadFinished().

void QGraphicsWebView::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::mouseDoubleClickEvent().

void QGraphicsWebView::mouseMoveEvent ( QGraphicsSceneMouseEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::mouseMoveEvent().

void QGraphicsWebView::mousePressEvent ( QGraphicsSceneMouseEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::mousePressEvent().

void QGraphicsWebView::mouseReleaseEvent ( QGraphicsSceneMouseEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::mouseReleaseEvent().

QWebPage * QGraphicsWebView::page () const

Returns a pointer to the underlying web page.

See also setPage().

QAction * QGraphicsWebView::pageAction ( QWebPage::WebAction action ) const

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

void QGraphicsWebView::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )   [virtual]

Reimplemented from QGraphicsItem::paint().

void QGraphicsWebView::reload ()   [slot]

Reloads the current document.

See also stop() and loadStarted().

bool QGraphicsWebView::sceneEvent ( QEvent * event )   [virtual protected]

Reimplemented from QGraphicsItem::sceneEvent().

void QGraphicsWebView::setContent ( const QByteArray & data, const QString & mimeType = QString(), const 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().

void QGraphicsWebView::setGeometry ( const QRectF & rect )   [virtual]

Reimplemented from QGraphicsLayoutItem::setGeometry().

void QGraphicsWebView::setHtml ( const QString & html, const 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.

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

void QGraphicsWebView::setPage ( QWebPage * page )

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().

QWebSettings * QGraphicsWebView::settings () const

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

It is equivalent to

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

See also QWebSettings::globalSettings().

QSizeF QGraphicsWebView::sizeHint ( Qt::SizeHint which, const QSizeF & constraint ) const   [virtual]

Reimplemented from QGraphicsLayoutItem::sizeHint().

void QGraphicsWebView::statusBarMessage ( const QString & text )   [signal]

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

void QGraphicsWebView::stop ()   [slot]

Convenience slot that stops loading the document.

See also reload() and loadFinished().

void QGraphicsWebView::titleChanged ( const QString & title )   [signal]

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

See also title().

void QGraphicsWebView::triggerPageAction ( 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().

void QGraphicsWebView::updateGeometry ()   [virtual]

Reimplemented from QGraphicsLayoutItem::updateGeometry().

void QGraphicsWebView::urlChanged ( const QUrl & url )   [signal]

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

See also url() and load().

void QGraphicsWebView::wheelEvent ( QGraphicsSceneWheelEvent * ev )   [virtual protected]

Reimplemented from QGraphicsItem::wheelEvent().


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt 4.6.0