QGraphicsWebView Class

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

頭: #include <QGraphicsWebView>
Since: Qt 4.6
繼承: QGraphicsWidget

特性

公共函數

QGraphicsWebView (QGraphicsItem * parent = 0)
~QGraphicsWebView ()
bool findText (const QString & subString , QWebPage::FindFlags options = 0)
QWebHistory * history () const
QIcon icon () const
bool isModified () const
bool isTiledBackingStoreFrozen () 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
QPainter::RenderHints renderHints () const
bool resizesToContents () 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 setRenderHint (QPainter::RenderHint hint , bool enabled = true)
void setRenderHints (QPainter::RenderHints hints )
void setResizesToContents (bool enabled )
void setTiledBackingStoreFrozen (bool frozen )
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

重實現公共函數

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

公共槽

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

信號

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 )

重實現保護函數

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 )

額外繼承成員

詳細描述

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 模塊。

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 而不是 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.

就像 QWebView , the item records the browsing history using a QWebHistory object, accessible using the history () 函數。 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.

另請參閱 QWebView and QGraphicsTextItem .

特性文檔編製

icon : const QIcon

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

默認情況下,此特性包含 null 圖標。

訪問函數:

QIcon icon () const

通知程序信號:

void iconChanged ()

另請參閱 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 屬性在 HTML 元素。

默認情況下,此特性為 false。

訪問函數:

bool isModified () const

renderHints : QPainter::RenderHints

This property holds the default render hints for the view.

這些提示用於初始化 QPainter before painting the Web page.

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

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

該特性在 Qt 4.8 引入。

訪問函數:

QPainter::RenderHints renderHints () const
void setRenderHints (QPainter::RenderHints hints )

另請參閱 QPainter::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, the QGraphicsWebView 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 the QWebPage::preferredContentsSize property. If not explicitly set, the preferredContentsSize is automatically set to a reasonable value.

該特性在 Qt 4.7 引入。

訪問函數:

bool resizesToContents () const
void setResizesToContents (bool enabled )

另請參閱 QWebPage::setPreferredContentsSize ().

tiledBackingStoreFrozen : bool

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

If the tiled backing store is enabled using QWebSettings::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 the QGraphicsWebView .

When the backing store is unfrozen, its contents will be automatically updated to match the current state of the document. If the QGraphicsWebView 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.

該特性在 Qt 4.7 引入。

訪問函數:

bool isTiledBackingStoreFrozen () const
void setTiledBackingStoreFrozen (bool frozen )

另請參閱 QWebSettings::TiledBackingStoreEnabled and QGraphicsObject::scale .

title : const QString

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

默認情況下,此特性包含空字符串。

訪問函數:

QString title () const

通知程序信號:

void titleChanged (const QString & title )

另請參閱 titleChanged().

url : QUrl

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

設置此特性清零視圖並加載 URL。

默認情況下,此特性包含空的無效 URL。

訪問函數:

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

通知程序信號:

void urlChanged (const QUrl & url )

另請參閱 load () and urlChanged().

zoomFactor : qreal

此特性保持視圖縮放因子。

訪問函數:

qreal zoomFactor () const
void setZoomFactor (qreal)

成員函數文檔編製

QGraphicsWebView:: QGraphicsWebView ( QGraphicsItem * parent = 0)

構造空的 QGraphicsWebView 采用父級 parent .

另請參閱 load ().

QGraphicsWebView:: ~QGraphicsWebView ()

Destroys the item.

[slot] void QGraphicsWebView:: back ()

方便槽,用於把先前文檔加載進由導航鏈接構建的文檔列錶。什麼都不做,若沒有先前文檔。

另請參閱 forward ().

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

重實現自 QGraphicsItem::contextMenuEvent ().

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

重實現自 QGraphicsItem::dragEnterEvent ().

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

重實現自 QGraphicsItem::dragLeaveEvent ().

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

重實現自 QGraphicsItem::dragMoveEvent ().

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

重實現自 QGraphicsItem::dropEvent ().

[虛擬] bool QGraphicsWebView:: event ( QEvent * event )

重實現自 QObject::event ().

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

查找指定字符串, subString ,在頁麵使用給定 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.

要清除選定,隻需傳遞空字符串。

返迴 true 若 subString was found; otherwise returns false.

另請參閱 QWebPage::selectedText () 和 QWebPage::selectionChanged ().

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

重實現自 QGraphicsItem::focusInEvent ().

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

重實現自 QGraphicsWidget::focusNextPrevChild ().

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

重實現自 QGraphicsItem::focusOutEvent ().

[slot] void QGraphicsWebView:: forward ()

方便槽,用於把下一文檔加載進由導航鏈接構建的文檔列錶。什麼都不做,若沒有下一文檔。

另請參閱 back ().

QWebHistory * QGraphicsWebView:: history () const

返迴指嚮導航網頁的視圖曆史的指針。

它相當於

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

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

重實現自 QGraphicsItem::hoverLeaveEvent ().

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

重實現自 QGraphicsItem::hoverMoveEvent ().

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

重實現自 QGraphicsItem::inputMethodEvent ().

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

重實現自 QGraphicsItem::inputMethodQuery ().

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

重實現自 QGraphicsItem::itemChange ().

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

重實現自 QGraphicsItem::keyPressEvent ().

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

重實現自 QGraphicsItem::keyReleaseEvent ().

[signal] void QGraphicsWebView:: linkClicked (const QUrl & 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 specified url .

另請參閱 QWebPage::linkDelegationPolicy ().

void QGraphicsWebView:: load (const QUrl & url )

加載指定 url 並顯示它。

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

另請參閱 setUrl (), url (),和 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.

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

另請參閱 url () 和 urlChanged ().

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

This signal is emitted when a load of the page is finished. ok 將指示加載是否成功 (或發生任何錯誤)。

另請參閱 loadStarted ().

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

當前值被提供由 progress 並縮放到 0 - 100,其是默認範圍為 QProgressBar .

另請參閱 loadStarted () 和 loadFinished ().

[signal] void QGraphicsWebView:: loadStarted ()

此信號被發射當頁麵的新加載開始時。

另請參閱 loadProgress () 和 loadFinished ().

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

重實現自 QGraphicsItem::mouseDoubleClickEvent ().

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

重實現自 QGraphicsItem::mouseMoveEvent ().

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

重實現自 QGraphicsItem::mousePressEvent ().

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

重實現自 QGraphicsItem::mouseReleaseEvent ().

QWebPage * QGraphicsWebView:: page () const

返迴指嚮底層 Web 頁麵的指針。

另請參閱 setPage ().

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

返迴指針指嚮 QAction 封裝指定的 Web 動作 action .

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

重實現自 QGraphicsItem::paint ().

[slot] void QGraphicsWebView:: reload ()

重新加載當前文檔。

另請參閱 stop () 和 loadStarted ().

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

重實現自 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 。若 mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.

內容中引用的外部對象的定位相對於 baseUrl .

The data 被立即加載;外部對象是異步加載的。

另請參閱 load (), setHtml (),和 QWebFrame::toHtml ().

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

重實現自 QGraphicsLayoutItem::setGeometry ().

void QGraphicsWebView:: setHtml (const QString & html , const QUrl & baseUrl = QUrl())

將 Web 視圖內容設為指定 html .

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

The html 被立即加載;外部對象是異步加載的。

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.

此方便函數相當於 setContent (html, "text/html", baseUrl).

警告: This function works only for HTML, for other mime types (i.e. XHTML, SVG) setContent () 應該被使用以取而代之。

另請參閱 load (), setContent (), QWebFrame::toHtml (),和 QWebFrame::setContent ().

void QGraphicsWebView:: setPage ( QWebPage * page )

使 page the new web page of the web graphicsitem.

父級 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.

另請參閱 page ().

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

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

該函數在 Qt 4.8 引入。

另請參閱 renderHints and QPainter::renderHints ().

QWebSettings * QGraphicsWebView:: settings () const

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

它相當於

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

另請參閱 QWebSettings::globalSettings ().

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

重實現自 QGraphicsLayoutItem::sizeHint ().

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

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

[slot] void QGraphicsWebView:: stop ()

停止加載文檔的方便槽。

另請參閱 reload () 和 loadFinished ().

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

觸發指定 action . If it is a checkable action the specified checked 假定狀態。

另請參閱 pageAction ().

[虛擬] void QGraphicsWebView:: updateGeometry ()

重實現自 QGraphicsLayoutItem::updateGeometry ().

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

重實現自 QGraphicsItem::wheelEvent ().