Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QGraphicsWebView Class

TheQGraphicsWebView class allows Web content to be added to aGraphicsView.More...

Header:#include <QGraphicsWebView>
Since: Qt 4.6
Inherits:QGraphicsWidget

Properties

Public Functions

QGraphicsWebView(QGraphicsItem * parent = 0)
~QGraphicsWebView()
boolfindText(const QString & subString, QWebPage::FindFlags options = 0)
QWebHistory *history() const
QIconicon() const
boolisModified() const
boolisTiledBackingStoreFrozen() const
voidload(const QUrl & url)
voidload(const QNetworkRequest & request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray())
QWebPage *page() const
QAction *pageAction(QWebPage::WebAction action) const
QPainter::RenderHintsrenderHints() const
boolresizesToContents() const
voidsetContent(const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl())
voidsetHtml(const QString & html, const QUrl & baseUrl = QUrl())
voidsetPage(QWebPage * page)
voidsetRenderHint(QPainter::RenderHint hint, bool enabled = true)
voidsetRenderHints(QPainter::RenderHints hints)
voidsetResizesToContents(bool enabled)
voidsetTiledBackingStoreFrozen(bool frozen)
voidsetUrl(const QUrl &)
voidsetZoomFactor(qreal)
QWebSettings *settings() const
QStringtitle() const
voidtriggerPageAction(QWebPage::WebAction action, bool checked = false)
QUrlurl() const
qrealzoomFactor() const

Reimplemented Public Functions

virtual boolevent(QEvent * event)
virtual QVariantinputMethodQuery(Qt::InputMethodQuery query) const
virtual QVariantitemChange(GraphicsItemChange change, const QVariant & value)
virtual voidpaint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0)
virtual voidsetGeometry(const QRectF & rect)
virtual QSizeFsizeHint(Qt::SizeHint which, const QSizeF & constraint) const
virtual voidupdateGeometry()

Public Slots

voidback()
voidforward()
voidreload()
voidstop()

Signals

voidiconChanged()
voidlinkClicked(const QUrl & url)
voidloadFinished(bool ok)
voidloadProgress(int progress)
voidloadStarted()
voidstatusBarMessage(const QString & text)
voidtitleChanged(const QString & title)
voidurlChanged(const QUrl & url)

Reimplemented Protected Functions

virtual voidcontextMenuEvent(QGraphicsSceneContextMenuEvent * ev)
virtual voiddragEnterEvent(QGraphicsSceneDragDropEvent * ev)
virtual voiddragLeaveEvent(QGraphicsSceneDragDropEvent * ev)
virtual voiddragMoveEvent(QGraphicsSceneDragDropEvent * ev)
virtual voiddropEvent(QGraphicsSceneDragDropEvent * ev)
virtual voidfocusInEvent(QFocusEvent * ev)
virtual boolfocusNextPrevChild(bool next)
virtual voidfocusOutEvent(QFocusEvent * ev)
virtual voidhoverLeaveEvent(QGraphicsSceneHoverEvent * ev)
virtual voidhoverMoveEvent(QGraphicsSceneHoverEvent * ev)
virtual voidinputMethodEvent(QInputMethodEvent * ev)
virtual voidkeyPressEvent(QKeyEvent * ev)
virtual voidkeyReleaseEvent(QKeyEvent * ev)
virtual voidmouseDoubleClickEvent(QGraphicsSceneMouseEvent * ev)
virtual voidmouseMoveEvent(QGraphicsSceneMouseEvent * ev)
virtual voidmousePressEvent(QGraphicsSceneMouseEvent * ev)
virtual voidmouseReleaseEvent(QGraphicsSceneMouseEvent * ev)
virtual boolsceneEvent(QEvent * event)
virtual voidwheelEvent(QGraphicsSceneWheelEvent * ev)

Additional Inherited Members

Detailed Description

TheQGraphicsWebView class allows Web content to be added to aGraphicsView.

An instance of this class renders Web content from a URL or supplied as data, using features of theQtWebKit 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 byQWebView are also available for this item, making it simple to adapt existing code to useQGraphicsWebView instead ofQWebView.

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

As withQWebView, the item records the browsing history using aQWebHistory object, accessible using thehistory() function. TheQWebSettings object that defines the configuration of the browser can be obtained with thesettings() function, enabling features like plugin support to be customized for each item.

See alsoQWebView andQGraphicsTextItem.

Property Documentation

icon : constQIcon

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

By default, this property contains a null icon.

Access functions:

QIconicon() const

Notifier signal:

voidiconChanged()

See alsoiconChanged() andQWebSettings::iconForUrl().

modified : constbool

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

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

By default, this property is false.

Access functions:

boolisModified() const

renderHints :QPainter::RenderHints

This property holds the default render hints for the view.

These hints are used to initializeQPainter before painting the Web page.

QPainter::TextAntialiasing andQPainter::SmoothPixmapTransform are enabled by default and will be used to render the item in addition of what has been set on the painter given byQGraphicsScene.

Note:This property is not available on Symbian. However, the getter and setter functions can still be used directly.

This property was introduced in Qt 4.8.

Access functions:

QPainter::RenderHintsrenderHints() const
voidsetRenderHints(QPainter::RenderHints hints)

See alsoQPainter::renderHints().

resizesToContents :bool

This property holds whether the size of the QGraphicsWebView and its viewport changes to match the contents size.

If this property is set, theQGraphicsWebView will automatically change its size to match the size of the main frame contents. As a result the top level frame will never have scrollbars. It will also make CSS fixed positioning to behave like absolute positioning with elements positioned relative to the document instead of the viewport.

This property should be used in conjunction with theQWebPage::preferredContentsSize property. If not explicitly set, the preferredContentsSize is automatically set to a reasonable value.

This property was introduced in Qt 4.7.

Access functions:

boolresizesToContents() const
voidsetResizesToContents(bool enabled)

See alsoQWebPage::setPreferredContentsSize().

tiledBackingStoreFrozen :bool

This property holds whether the tiled backing store updates its contents.

If the tiled backing store is enabled usingQWebSettings::TiledBackingStoreEnabled attribute, this property can be used to disable backing store updates temporarily. This can be useful for example for running a smooth animation that changes the scale of theQGraphicsWebView.

When the backing store is unfrozen, its contents will be automatically updated to match the current state of the document. If theQGraphicsWebView scale was changed, the backing store is also re-rendered using the new scale.

If the tiled backing store is not enabled, this property does nothing.

This property was introduced in Qt 4.7.

Access functions:

boolisTiledBackingStoreFrozen() const
voidsetTiledBackingStoreFrozen(bool frozen)

See alsoQWebSettings::TiledBackingStoreEnabled andQGraphicsObject::scale.

title : constQString

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

By default, this property contains an empty string.

Access functions:

QStringtitle() const

Notifier signal:

voidtitleChanged(const QString & title)

See alsotitleChanged().

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:

QUrlurl() const
voidsetUrl(const QUrl &)

Notifier signal:

voidurlChanged(const QUrl & url)

See alsoload() and urlChanged().

zoomFactor :qreal

This property holds the zoom factor for the view.

Access functions:

qrealzoomFactor() const
voidsetZoomFactor(qreal)

Member Function Documentation

QGraphicsWebView::QGraphicsWebView(QGraphicsItem * parent = 0)

Constructs an emptyQGraphicsWebView with parentparent.

See alsoload().

QGraphicsWebView::~QGraphicsWebView()

Destroys the item.

[slot]void QGraphicsWebView::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 alsoforward().

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

Reimplemented fromQGraphicsItem::contextMenuEvent().

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

Reimplemented fromQGraphicsItem::dragEnterEvent().

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

Reimplemented fromQGraphicsItem::dragLeaveEvent().

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

Reimplemented fromQGraphicsItem::dragMoveEvent().

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

Reimplemented fromQGraphicsItem::dropEvent().

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

Reimplemented fromQObject::event().

bool QGraphicsWebView::findText(constQString & subString,QWebPage::FindFlags options = 0)

Finds the specified string,subString, in the page, using the givenoptions.

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 ifsubString was found; otherwise returns false.

See alsoQWebPage::selectedText() andQWebPage::selectionChanged().

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

Reimplemented fromQGraphicsItem::focusInEvent().

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

Reimplemented fromQGraphicsWidget::focusNextPrevChild().

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

Reimplemented fromQGraphicsItem::focusOutEvent().

[slot]void QGraphicsWebView::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 alsoback().

QWebHistory * QGraphicsWebView::history() const

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

It is equivalent to

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

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

Reimplemented fromQGraphicsItem::hoverLeaveEvent().

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

Reimplemented fromQGraphicsItem::hoverMoveEvent().

[virtual protected]void QGraphicsWebView::inputMethodEvent(QInputMethodEvent * ev)

Reimplemented fromQGraphicsItem::inputMethodEvent().

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

Reimplemented fromQGraphicsItem::inputMethodQuery().

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

Reimplemented fromQGraphicsItem::itemChange().

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

Reimplemented fromQGraphicsItem::keyPressEvent().

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

Reimplemented fromQGraphicsItem::keyReleaseEvent().

[signal]void QGraphicsWebView::linkClicked(constQUrl & url)

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 specifiedurl.

See alsoQWebPage::linkDelegationPolicy().

void QGraphicsWebView::load(constQUrl & url)

Loads the specifiedurl and displays it.

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

See alsosetUrl(),url(), andurlChanged().

void QGraphicsWebView::load(constQNetworkRequest & request,QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, constQByteArray & body = QByteArray())

Loads a network request,request, using the method specified inoperation.

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

[signal]void QGraphicsWebView::loadFinished(bool ok)

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

[signal]void QGraphicsWebView::loadProgress(int progress)

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 byprogress and scales from 0 to 100, which is the default range ofQProgressBar.

See alsoloadStarted() andloadFinished().

[signal]void QGraphicsWebView::loadStarted()

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

See alsoloadProgress() andloadFinished().

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

Reimplemented fromQGraphicsItem::mouseDoubleClickEvent().

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

Reimplemented fromQGraphicsItem::mouseMoveEvent().

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

Reimplemented fromQGraphicsItem::mousePressEvent().

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

Reimplemented fromQGraphicsItem::mouseReleaseEvent().

QWebPage * QGraphicsWebView::page() const

Returns a pointer to the underlying web page.

See alsosetPage().

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

Returns a pointer to aQAction that encapsulates the specified web actionaction.

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

Reimplemented fromQGraphicsItem::paint().

[slot]void QGraphicsWebView::reload()

Reloads the current document.

See alsostop() andloadStarted().

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

Reimplemented fromQGraphicsItem::sceneEvent().

void QGraphicsWebView::setContent(constQByteArray & data, constQString & mimeType = QString(), constQUrl & baseUrl = QUrl())

Sets the content of the web graphicsitem to the specified contentdata. If themimeType 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 tobaseUrl.

Thedata is loaded immediately; external objects are loaded asynchronously.

See alsoload(),setHtml(), andQWebFrame::toHtml().

[virtual]void QGraphicsWebView::setGeometry(constQRectF & rect)

Reimplemented fromQGraphicsLayoutItem::setGeometry().

void QGraphicsWebView::setHtml(constQString & html, constQUrl & baseUrl = QUrl())

Sets the content of the web view to the specifiedhtml.

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

Thehtml 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 tosetContent(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 alsoload(),setContent(),QWebFrame::toHtml(), andQWebFrame::setContent().

void QGraphicsWebView::setPage(QWebPage * page)

Makespage the new web page of the web graphicsitem.

The parentQObject 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 alsopage().

void QGraphicsWebView::setRenderHint(QPainter::RenderHint hint,bool enabled = true)

Ifenabled is true, enables the specified renderhint; otherwise disables it.

This function was introduced in Qt 4.8.

See alsorenderHints andQPainter::renderHints().

QWebSettings * QGraphicsWebView::settings() const

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

It is equivalent to

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

See alsoQWebSettings::globalSettings().

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

Reimplemented fromQGraphicsLayoutItem::sizeHint().

[signal]void QGraphicsWebView::statusBarMessage(constQString & text)

This signal is emitted when the statusbartext is changed by the page.

[slot]void QGraphicsWebView::stop()

Convenience slot that stops loading the document.

See alsoreload() andloadFinished().

void QGraphicsWebView::triggerPageAction(QWebPage::WebAction action,bool checked = false)

Triggers the specifiedaction. If it is a checkable action the specifiedchecked state is assumed.

See alsopageAction().

[virtual]void QGraphicsWebView::updateGeometry()

Reimplemented fromQGraphicsLayoutItem::updateGeometry().

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

Reimplemented fromQGraphicsItem::wheelEvent().

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp