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.
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 .
This property holds the icon associated with the web page currently viewed.
默认情况下,此特性包含 null 图标。
访问函数:
| QIcon | icon () const |
通知程序信号:
| void | iconChanged () |
另请参阅 iconChanged() and QWebSettings::iconForUrl ().
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 |
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 ().
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 ().
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 .
This property holds the title of the web page currently viewed.
默认情况下,此特性包含空字符串。
访问函数:
| QString | title () const |
通知程序信号:
| void | titleChanged (const QString & title ) |
另请参阅 titleChanged().
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().
此特性保持视图缩放因子。
访问函数:
| qreal | zoomFactor () const |
| void | setZoomFactor (qreal) |
构造空的 QGraphicsWebView 采用父级 parent .
另请参阅 load ().
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 ().
查找指定字符串, 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 ().
返回指向导航网页的视图历史的指针。
它相当于
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 ().
加载指定 url 并显示它。
注意: The view remains the same until enough data has arrived to display the new url .
另请参阅 setUrl (), url (),和 urlChanged ().
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 ().
返回指向底层 Web 页面的指针。
另请参阅 setPage ().
返回指针指向 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 ().
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 ().
将 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 ().
使 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 ().
若 enabled is true, enables the specified render hint ; otherwise disables it.
该函数在 Qt 4.8 引入。
另请参阅 renderHints and QPainter::renderHints ().
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 ().
触发指定 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 ().