QWebPage Class Reference

[ QtWebKit module]

The QWebPage class provides an object to view and edit web documents. 更多...

继承 QObject .

类型

方法

Qt Signals


详细描述

The QWebPage class provides an object to view and edit web documents.

QWebPage holds a main frame responsible for web content, settings, the history of navigated links and actions. This class can be used, together with QWebFrame , to provide functionality like QWebView in a widget-less environment.

QWebPage's API is very similar to QWebView , as you are still provided with common functions like action () (known as pageAction () 在 QWebView ), triggerAction (), findText () 和 settings (). More QWebView -like functions can be found in the main frame of QWebPage, obtained via the mainFrame () function. For example, the load (), setUrl () 和 setHtml () functions for QWebPage can be accessed using QWebFrame .

loadStarted () signal is emitted when the page begins to load.The loadProgress () signal, on the other hand, is emitted whenever an element of the web page completes loading, such as an embedded image, a script, etc. Finally, the loadFinished () 信号被发射 when the page contents are loaded completely, independent of script execution or page rendering. Its argument, either true or false, indicates whether or not the load operation succeeded.

Using QWebPage in a Widget-less Environment

Before you begin painting a QWebPage object, you need to set the size of the viewport by calling setViewportSize (). Then, you invoke the main frame's render function ( QWebFrame.render ()). An example of this is shown in the code snippet below.

Suppose we have a Thumbnail class as follows:

 class Thumbnailer : public QObject
 {
     Q_OBJECT
 public:
     Thumbnailer(const QUrl &url);
 signals:
     void finished();
 private slots:
     void render();
 private:
     QWebPage page;
 };
			

Thumbnail 's constructor takes in a url . We connect our QWebPage object's loadFinished() signal to our private slot, render() .

 Thumbnailer.Thumbnailer(const QUrl &url)
 {
     page.mainFrame()->load(url);
     connect(&page, SIGNAL(loadFinished(bool)),
         this, SLOT(render()));
 }
			

render() function shows how we can paint a thumbnail using a QWebPage object.

 void Thumbnailer.render()
 {
     page.setViewportSize(page.mainFrame()->contentsSize());
     QImage image(page.viewportSize(), QImage.Format_ARGB32);
     QPainter painter(&image);
     page.mainFrame()->render(&painter);
     painter.end();
     QImage thumbnail = image.scaled(400, 400);
     thumbnail.save("thumbnail.png");
     emit finished();
 }
			

We begin by setting the viewportSize and then we instantiate a QImage 对象, image , with the same size as our viewportSize . This image is then sent as a parameter to painter . Next, we render the contents of the main frame and its subframes into painter . Finally, we save the scaled image.


类型文档编制

QWebPage.ErrorDomain

This enum describes the domain of an ErrorPageExtensionOption object (i.e. the layer in which the error occurred).

常量 描述
QWebPage.QtNetwork 0 The error occurred in the QtNetwork layer; the error code is of type QNetworkReply.NetworkError .
QWebPage.Http 1 The error occurred in the HTTP layer; the error code is a HTTP status code (see QNetworkRequest.HttpStatusCodeAttribute ).
QWebPage.WebKit 2 The error is an internal WebKit error.

该枚举在 Qt 4.6 引入或被修改。

QWebPage.Extension

This enum describes the types of extensions that the page can support. Before using these extensions, you should verify that the extension is supported by calling supportsExtension ().

常量 描述
QWebPage.ChooseMultipleFilesExtension 0 Whether the web page supports multiple file selection. This extension is invoked when the web content requests one or more file names, for example as a result of the user clicking on a "file upload" button in a HTML form where multiple file selection is allowed.
QWebPage.ErrorPageExtension 1 Whether the web page can provide an error page when loading fails. (introduced in Qt 4.6)

另请参阅 ChooseMultipleFilesExtensionOption , ChooseMultipleFilesExtensionReturn , ErrorPageExtensionOption , and ErrorPageExtensionReturn .

QWebPage.Feature

QWebPage.FindFlag

此枚举描述的选项可用于 findText () function. The options can be OR-ed together from the following list:

常量 描述
QWebPage.FindBackward 1 向后搜索,而不是向前。
QWebPage.FindCaseSensitively 2 默认情况下 findText () works case insensitive. Specifying this option changes the behaviour to a case sensitive find operation.
QWebPage.FindWrapsAroundDocument 4 Makes findText () restart from the beginning of the document if the end was reached and the text was not found.
QWebPage.HighlightAllOccurrences 8 Highlights all existing occurrences of a specific string. (This value was introduced in 4.6.)

FindFlags 类型是 typedef 对于 QFlags <FindFlag>. It stores an OR combination of FindFlag values.

QWebPage.LinkDelegationPolicy

This enum defines the delegation policies a webpage can have when activating links and emitting the linkClicked () 信号。

常量 描述
QWebPage.DontDelegateLinks 0 No links are delegated. Instead, QWebPage tries to handle them all.
QWebPage.DelegateExternalLinks 1 When activating links that point to documents not stored on the local filesystem or an equivalent - such as the Qt resource system - then linkClicked () 被发射。
QWebPage.DelegateAllLinks 2 Whenever a link is activated the linkClicked () signal is emitted.

另请参阅 QWebPage.linkDelegationPolicy .

QWebPage.NavigationType

This enum describes the types of navigation available when browsing through hyperlinked documents.

常量 描述
QWebPage.NavigationTypeLinkClicked 0 The user clicked on a link or pressed return on a focused link.
QWebPage.NavigationTypeFormSubmitted 1 The user activated a submit button for an HTML form.
QWebPage.NavigationTypeBackOrForward 2 Navigation to a previously shown document in the back or forward history is requested.
QWebPage.NavigationTypeReload 3 The user activated the reload action.
QWebPage.NavigationTypeFormResubmitted 4 An HTML form was submitted a second time.
QWebPage.NavigationTypeOther 5 A navigation to another document using a method not listed above.

另请参阅 acceptNavigationRequest ().

QWebPage.PermissionPolicy

QWebPage.WebAction

This enum describes the types of action which can be performed on the web page.

Actions only have an effect when they are applicable. The availability of actions can be be determined by checking isEnabled() on the action returned by action ().

One method of enabling the text editing, cursor movement, and text selection actions is by setting contentEditable to true.

常量 描述
QWebPage.NoWebAction -1 没有动作被触发。
QWebPage.OpenLink 0 打开当前链接。
QWebPage.OpenLinkInNewWindow 1 Open the current link in a new window.
QWebPage.OpenFrameInNewWindow 2 Replicate the current frame in a new 窗口。
QWebPage.DownloadLinkToDisk 3 Download the current link to the disk.
QWebPage.CopyLinkToClipboard 4 Copy the current link to the clipboard.
QWebPage.OpenImageInNewWindow 5 Open the highlighted image in a new 窗口。
QWebPage.DownloadImageToDisk 6 Download the highlighted image to the disk.
QWebPage.CopyImageToClipboard 7 Copy the highlighted image to the clipboard.
QWebPage.CopyImageUrlToClipboard 68 Copy the highlighted image's URL to the clipboard.
QWebPage.Back 8 Navigate back in the history of navigated links.
QWebPage.Forward 9 Navigate forward in the history of navigated links.
QWebPage.Stop 10 停止加载当前页面。
QWebPage.StopScheduledPageRefresh 67 Stop all pending page refresh/redirect requests.
QWebPage.Reload 11 重新加载当前页面。
QWebPage.ReloadAndBypassCache 53 Reload the current page, but do not use any local cache. (Added in Qt 4.6)
QWebPage.Cut 12 Cut the content currently selected into the clipboard.
QWebPage.Copy 13 Copy the content currently selected into the clipboard.
QWebPage.Paste 14 从剪贴板粘贴内容。
QWebPage.Undo 15 撤消上一编辑动作。
QWebPage.Redo 16 重做上一编辑动作。
QWebPage.MoveToNextChar 17 把光标移动到下一字符。
QWebPage.MoveToPreviousChar 18 Move the cursor to the previous character.
QWebPage.MoveToNextWord 19 把光标移动到下一单词。
QWebPage.MoveToPreviousWord 20 把光标移动到上一单词。
QWebPage.MoveToNextLine 21 Move the cursor to the next line.
QWebPage.MoveToPreviousLine 22 Move the cursor to the previous line.
QWebPage.MoveToStartOfLine 23 Move the cursor to the start of the line.
QWebPage.MoveToEndOfLine 24 Move the cursor to the end of the line.
QWebPage.MoveToStartOfBlock 25 Move the cursor to the start of the 块。
QWebPage.MoveToEndOfBlock 26 Move the cursor to the end of the block.
QWebPage.MoveToStartOfDocument 27 Move the cursor to the start of the 文档。
QWebPage.MoveToEndOfDocument 28 Move the cursor to the end of the 文档。
QWebPage.SelectNextChar 29 Select to the next character.
QWebPage.SelectPreviousChar 30 Select to the previous character.
QWebPage.SelectNextWord 31 Select to the next word.
QWebPage.SelectPreviousWord 32 Select to the previous word.
QWebPage.SelectNextLine 33 Select to the next line.
QWebPage.SelectPreviousLine 34 Select to the previous line.
QWebPage.SelectStartOfLine 35 Select to the start of the line.
QWebPage.SelectEndOfLine 36 Select to the end of the line.
QWebPage.SelectStartOfBlock 37 Select to the start of the block.
QWebPage.SelectEndOfBlock 38 Select to the end of the block.
QWebPage.SelectStartOfDocument 39 Select to the start of the document.
QWebPage.SelectEndOfDocument 40 Select to the end of the document.
QWebPage.DeleteStartOfWord 41 Delete to the start of the word.
QWebPage.DeleteEndOfWord 42 Delete to the end of the word.
QWebPage.SetTextDirectionDefault 43 Set the text direction to the default direction.
QWebPage.SetTextDirectionLeftToRight 44 Set the text direction to left-to-right.
QWebPage.SetTextDirectionRightToLeft 45 Set the text direction to right-to-left.
QWebPage.ToggleBold 46 Toggle the formatting between bold and normal weight.
QWebPage.ToggleItalic 47 Toggle the formatting between italic and normal style.
QWebPage.ToggleUnderline 48 Toggle underlining.
QWebPage.InspectElement 49 Show the Web Inspector with the currently highlighted HTML element.
QWebPage.InsertParagraphSeparator 50 Insert a new paragraph.
QWebPage.InsertLineSeparator 51 Insert a new line.
QWebPage.SelectAll 52 Selects all content.
QWebPage.PasteAndMatchStyle 54 Paste content from the clipboard with current style.
QWebPage.RemoveFormat 55 Removes formatting and style.
QWebPage.ToggleStrikethrough 56 Toggle the formatting between strikethrough and normal style.
QWebPage.ToggleSubscript 57 Toggle the formatting between subscript and baseline.
QWebPage.ToggleSuperscript 58 Toggle the formatting between supercript and baseline.
QWebPage.InsertUnorderedList 59 Toggles the selection between an ordered list and a normal block.
QWebPage.InsertOrderedList 60 Toggles the selection between an ordered list and a normal block.
QWebPage.Indent 61 Increases the indentation of the currently selected format block by one increment.
QWebPage.Outdent 62 Decreases the indentation of the currently selected format block by one increment.
QWebPage.AlignCenter 63 Applies center alignment to content.
QWebPage.AlignJustified 64 Applies full justification to content.
QWebPage.AlignLeft 65 Applies left justification to content.
QWebPage.AlignRight 66 Applies right justification to content.

QWebPage.WebWindowType

This enum describes the types of window that can be created by the createWindow () 函数。

常量 描述
QWebPage.WebBrowserWindow 0 The window is a regular web browser 窗口。
QWebPage.WebModalDialog 1 The window acts as modal dialog.

方法文档编制

QWebPage.__init__ ( self , QObject   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

构造空 QWebPage with parent parent .

bool QWebPage.acceptNavigationRequest ( self , QWebFrame   frame , QNetworkRequest   request , NavigationType   type )

This function is called whenever WebKit requests to navigate frame to the resource specified by request by means of the specified navigation type type .

frame is a null pointer then navigation to a new window is requested. If the request is accepted createWindow () will be called.

The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true to let QWebPage handle the navigation itself.

另请参阅 createWindow ().

QAction QWebPage.action ( self , WebAction   action )

返回 QAction 为指定 WebAction action .

动作归 QWebPage 但可以通过改变其特性定制外观。

QWebPage also takes care of implementing the action, so that upon triggering the corresponding action is performed on the page.

另请参阅 triggerAction ().

int QWebPage.bytesReceived ( self )

Returns the number of bytes that were received from the network to render the current page.

另请参阅 totalBytes () 和 loadProgress ().

QString QWebPage.chooseFile ( self , QWebFrame   originatingFrame , QString  oldFile )

This function is called when the web content requests a file name, for example as a result of the user clicking on a "file upload" button in a HTML form.

A suggested filename may be provided in suggestedFile . The frame originating the request is provided as parentFrame .

另请参阅 ChooseMultipleFilesExtension .

QObject QWebPage.createPlugin ( self , QString  classid , QUrl   url , QStringList  paramNames , QStringList  paramValues )

This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin". It is called regardless of the value of QWebSettings.PluginsEnabled . classid , url , paramNames and paramValues correspond to the HTML object element attributes and child elements to configure the embeddable object.

QMenu QWebPage.createStandardContextMenu ( self )

This function creates the standard context menu which is shown when the user clicks on the web page with the right mouse button. It is called from the default contextMenuEvent() handler. The popup menu's ownership is transferred to the caller.

该函数在 Qt 4.5 引入。

QWebPage QWebPage.createWindow ( self , WebWindowType   type )

This function is called whenever WebKit wants to create a new window of the given type , for example when a JavaScript program requests to open a document in a new window.

若新窗口可以被创建,新窗口的 QWebPage is returned; otherwise a null pointer 被返回。

若网页关联视图为 QWebView object, then the default implementation forwards the request to QWebView 's createWindow() function; otherwise it returns a null pointer.

type is WebModalDialog , application must call setWindowModality( Qt.ApplicationModal ) on the new 窗口。

注意: In the cases when the window creation is being triggered by JavaScript, apart from reimplementing this method application must also set the JavaScriptCanOpenWindows attribute of QWebSettings to true in order for it to get called.

另请参阅 acceptNavigationRequest () and QWebView.createWindow ().

QWebFrame QWebPage.currentFrame ( self )

Returns the frame currently active.

另请参阅 mainFrame () 和 frameCreated ().

bool QWebPage.event ( self , QEvent )

重实现自 QObject.event ().

bool QWebPage.extension ( self , Extension   extension , ExtensionOption   option  = None, ExtensionReturn   output  = None)

This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The option argument is provided as input to the extension; the output results can be stored in output .

The behavior of this function is determined by extension . option and output values are typically casted to the corresponding types (for example, ChooseMultipleFilesExtensionOption and ChooseMultipleFilesExtensionReturn for ChooseMultipleFilesExtension ).

可以调用 supportsExtension () to check if an extension is supported by the page.

Returns true if the extension was called successfully; otherwise returns false.

另请参阅 supportsExtension () 和 Extension .

bool QWebPage.findText ( self , QString  subString , FindFlags   options  = 0)

查找指定字符串, subString , in the page, using the given options .

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.

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.

bool QWebPage.focusNextPrevChild ( self , bool  next )

类似 QWidget.focusNextPrevChild () it focuses the next focusable web element if next is true; otherwise the previous element is focused.

Returns true if it can find a new focusable element, or false if it can't.

bool QWebPage.forwardUnsupportedContent ( self )

QWebFrame QWebPage.frameAt ( self , QPoint   pos )

Returns the frame at the given point pos , or 0 if there is no frame at that position.

该函数在 Qt 4.6 引入。

另请参阅 mainFrame () 和 currentFrame ().

bool QWebPage.hasSelection ( self )

QWebHistory QWebPage.history ( self )

Returns a pointer to the view's history of navigated web 页面。

QVariant QWebPage.inputMethodQuery ( self , Qt.InputMethodQuery   property )

This method is used by the input method to query a set of properties of the page to be able to support complex input method operations as support for surrounding text and reconversions.

property 指定要查询的特性。

另请参阅 QWidget.inputMethodEvent (), QInputMethodEvent ,和 QInputContext .

bool QWebPage.isContentEditable ( self )

bool QWebPage.isModified ( self )

QWebPage.javaScriptAlert ( self , QWebFrame   originatingFrame , QString  msg )

This function is called whenever a JavaScript program running inside frame calls the alert() function with the message msg .

默认实现展示消息, msg ,采用 QMessageBox.information.

bool QWebPage.javaScriptConfirm ( self , QWebFrame   originatingFrame , QString  msg )

This function is called whenever a JavaScript program running inside frame calls the confirm() function with the message, msg . Returns true if the user confirms the message; otherwise returns false.

默认实现执行查询使用 QMessageBox.information with QMessageBox.Yes and QMessageBox.No 按钮。

QWebPage.javaScriptConsoleMessage ( self , QString  message , int  lineNumber , QString  sourceID )

This function is called whenever a JavaScript program tries to print a message to the web browser's console.

For example in case of evaluation errors the source URL may be provided in sourceID as well as the lineNumber .

The default implementation prints nothing.

(bool, QString  result ) QWebPage.javaScriptPrompt ( self , QWebFrame   originatingFrame , QString  msg , QString  defaultValue )

This function is called whenever a JavaScript program running inside frame tries to prompt the user for input. The program may provide an optional message, msg , as well as a default value for the input in defaultValue .

If the prompt was cancelled by the user the implementation should return false; otherwise the result should be written to result and true should be returned. If the prompt was not cancelled by the user, the implementation should return true and the result string must not be null.

默认实现使用 QInputDialog.getText ().

bool QWebPage.javaScriptPrompt ( self , QWebFrame   originatingFrame , QString  msg , QString  defaultValue , QString  result )

LinkDelegationPolicy QWebPage.linkDelegationPolicy ( self )

QWebFrame QWebPage.mainFrame ( self )

Returns the main frame of the page.

The main frame provides access to the hierarchy of sub-frames and is also needed if you want to explicitly render a web page into a given painter.

另请参阅 currentFrame ().

QNetworkAccessManager QWebPage.networkAccessManager ( self )

返回 QNetworkAccessManager that is responsible for serving network requests for this QWebPage .

另请参阅 setNetworkAccessManager ().

QPalette QWebPage.palette ( self )

QWebPluginFactory QWebPage.pluginFactory ( self )

返回 QWebPluginFactory that is responsible for creating plugins embedded into this QWebPage . If no plugin factory is installed a null pointer is returned.

另请参阅 setPluginFactory ().

QSize QWebPage.preferredContentsSize ( self )

QString QWebPage.selectedHtml ( self )

QString QWebPage.selectedText ( self )

QWebPage.setActualVisibleContentRect ( self , QRect   rect )

QWebPage.setContentEditable ( self , bool  editable )

QWebPage.setFeaturePermission ( self , QWebFrame   frame , Feature   feature , PermissionPolicy   policy )

QWebPage.setForwardUnsupportedContent ( self , bool  forward )

QWebPage.setLinkDelegationPolicy ( self , LinkDelegationPolicy   policy )

QWebPage.setNetworkAccessManager ( self , QNetworkAccessManager   manager )

设置 QNetworkAccessManager manager responsible for serving network requests for this QWebPage .

注意: It is currently not supported to change the network access manager after the QWebPage has used it. The results of doing this are undefined.

另请参阅 networkAccessManager ().

QWebPage.setPalette ( self , QPalette   palette )

QWebPage.setPluginFactory ( self , QWebPluginFactory   factory )

设置 QWebPluginFactory factory responsible for creating plugins embedded into this QWebPage .

Note: The plugin factory is only used if the QWebSettings.PluginsEnabled attribute is enabled.

另请参阅 pluginFactory ().

QWebPage.setPreferredContentsSize ( self , QSize   size )

QWebSettings QWebPage.settings ( self )

返回指向页面设置对象的指针。

另请参阅 QWebSettings.globalSettings ().

QWebPage.setView ( self , QWidget   view )

设置 view 关联网页。

另请参阅 view ().

QWebPage.setViewportSize ( self , QSize   size )

bool QWebPage.shouldInterruptJavaScript ( self )

This method is also a Qt slot with the C++ signature bool shouldInterruptJavaScript() .

This function is called when a JavaScript program is running for a long period of time.

If the user wanted to stop the JavaScript the implementation should return true; otherwise false.

默认实现执行查询使用 QMessageBox.information with QMessageBox.Yes and QMessageBox.No 按钮。

警告: Because of binary compatibility constraints, this function is not virtual. If you want to provide your own implementation in a QWebPage 子类, reimplement the shouldInterruptJavaScript() slot in your subclass 代替。 QtWebKit will dynamically detect the slot and call it.

该函数在 Qt 4.6 引入。

QStringList QWebPage.supportedContentTypes ( self )

Returns the list of all content types supported by QWebPage .

bool QWebPage.supportsContentType ( self , QString  mimeType )

返回 true 若 QWebPage can handle the given mimeType ; otherwise, returns false.

bool QWebPage.supportsExtension ( self , Extension   extension )

This virtual function returns true if the web page supports extension ;否则 false 被返回。

另请参阅 extension ().

bool QWebPage.swallowContextMenuEvent ( self , QContextMenuEvent   event )

Filters the context menu event, event , through handlers for scrollbars and custom event handlers in the web page. Returns true if the event was handled; otherwise false.

A web page may swallow a context menu event through a custom event handler, allowing for context menus to be implemented in HTML/JavaScript. This is used by Google Maps , for example.

int QWebPage.totalBytes ( self )

Returns the total number of bytes that were received from the network to render the current page, including extra content such as embedded images.

另请参阅 bytesReceived ().

QWebPage.triggerAction ( self , WebAction   action , bool  checked  = False)

此函数可以被调用以触发指定 action . It is also called by QtWebKit if the user triggers the action, for example through a context menu item.

action is a checkable action then checked specified whether the action is toggled or not.

另请参阅 action ().

QUndoStack QWebPage.undoStack ( self )

Returns a pointer to the undo stack used for editable 内容。

另请参阅 modified .

QWebPage.updatePositionDependentActions ( self , QPoint   pos )

Updates the page's actions depending on the position pos . For example if pos is over an image element the CopyImageToClipboard action is enabled.

QString QWebPage.userAgentForUrl ( self , QUrl   url )

This function is called when a user agent for HTTP requests is needed. You can reimplement this function to dynamically return different user agents for different URLs, based on the url 参数。

The default implementation returns the following value:

"Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"

On mobile platforms such as Symbian S60 and Maemo, "Mobile Safari" is used instead of "Safari".

In this string the following values are replaced at run-time:

QWidget QWebPage.view ( self )

Returns the view widget that is associated with the web 页面。

另请参阅 setView ().

ViewportAttributes QWebPage.viewportAttributesForSize ( self , QSize   availableSize )

Computes the optimal viewport configuration given the availableSize , when user interface components are disregarded.

The configuration is also dependent on the device screen size which is obtained automatically. For testing purposes the size can be overridden by setting two environment variables QTWEBKIT_DEVICE_WIDTH and QTWEBKIT_DEVICE_HEIGHT, which both needs to be set.

ViewportAttributes includes a pixel density ratio, which will also be exposed to the web author though the -webkit-pixel-ratio media feature. This is the ratio between 1 density-independent pixel (DPI) and physical pixels.

A density-independent pixel is equivalent to one physical pixel on a 160 DPI screen, so on our platform assumes that as the baseline density.

The conversion of DIP units to screen pixels is quite simple:

pixels = DIPs * (density / 160).

Thus, on a 240 DPI screen, 1 DIPs would equal 1.5 physical 像素。

An invalid instance will be returned in the case an empty size is passed to the method.

注意: The density is automatically obtained from the DPI of the screen where the page is being shown, but as many X11 servers are reporting wrong DPI, it is possible to override it 使用 QX11Info.setAppDpiY ().

QSize QWebPage.viewportSize ( self )


Qt Signal Documentation

void applicationCacheQuotaExceeded (QWebSecurityOrigin*,quint64)

This is the default overload of this signal.

This signal is emitted whenever the web site is asking to store data to the application cache database databaseName and the quota allocated to that web site is exceeded.

void contentsChanged ()

This is the default overload of this signal.

This signal is emitted whenever the text in form elements changes as well as other editable content.

该函数在 Qt 4.5 引入。

另请参阅 contentEditable , modified , QWebFrame.toHtml (),和 QWebFrame.toPlainText ().

void databaseQuotaExceeded (QWebFrame*,QString)

This is the default overload of this signal.

This signal is emitted whenever the web site shown in frame is asking to store data to the database databaseName and the quota allocated to that web site is exceeded.

该函数在 Qt 4.5 引入。

另请参阅 QWebDatabase .

void downloadRequested (const QNetworkRequest&)

This is the default overload of this signal.

This signal is emitted when the user decides to download a link. The url of the link as well as additional meta-information is contained in request .

另请参阅 unsupportedContent ().

void featurePermissionRequestCanceled (QWebFrame*,QWebPage::Feature)

This is the default overload of this signal.

void featurePermissionRequested (QWebFrame*,QWebPage::Feature)

This is the default overload of this signal.

void frameCreated (QWebFrame*)

This is the default overload of this signal.

This signal is emitted whenever the page creates a new frame .

另请参阅 currentFrame ().

void geometryChangeRequested (const QRect&)

This is the default overload of this signal.

This signal is emitted whenever the document wants to change the position and size of the page to geom . This can happen for example through JavaScript.

void linkClicked (const QUrl&)

This is the default overload of this 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 .

By default no links are delegated and are handled by QWebPage 代替。

注意: This signal possibly won't be emitted for clicked links which use JavaScript to trigger navigation.

另请参阅 linkHovered ().

void linkHovered (const QString&,const QString&,const QString&)

This is the default overload of this signal.

此信号被发射当鼠标悬停链接上时。

link contains the link url. title is the link element's title, if it is specified in the markup. textContent provides text within the link element, e.g., text inside an HTML anchor tag.

When the mouse leaves the link element the signal is emitted with empty parameters.

另请参阅 linkClicked ().

void loadFinished (bool)

This is the default overload of this signal.

This signal is emitted when the page finishes loading content. This signal is independant of script execution or page rendering. ok will indicate whether the load was successful or any error occurred.

另请参阅 loadStarted () 和 ErrorPageExtension .

void loadProgress (int)

This is the default overload of this signal.

This signal is emitted when the global progress status changes. 当前值被提供由 progress and scales from 0 to 100, which is the default range of QProgressBar . It accumulates changes from all the child frames.

另请参阅 bytesReceived ().

void loadStarted ()

This is the default overload of this signal.

此信号被发射当页面开始加载内容。

另请参阅 loadFinished ().

void menuBarVisibilityChangeRequested (bool)

This is the default overload of this signal.

This signal is emitted whenever the visibility of the menubar in a web browser window that hosts QWebPage should be changed to visible .

void microFocusChanged ()

This is the default overload of this signal.

This signal is emitted when for example the position of the cursor in an editable form element changes. It is used to inform input methods about the new on-screen position where the user is able to enter text. This signal is usually connected to the QWidget.updateMicroFocus () 槽。

void printRequested (QWebFrame*)

This is the default overload of this signal.

This signal is emitted whenever the page requests the web browser to print frame , for example through the JavaScript window.print() 调用。

另请参阅 QWebFrame.print () 和 QPrintPreviewDialog .

void repaintRequested (const QRect&)

This is the default overload of this signal.

This signal is emitted whenever this QWebPage should be updated. It's useful when rendering a QWebPage without a QWebView or QGraphicsWebView . dirtyRect contains the area that needs to be updated. To paint the QWebPage get the mainFrame () and call the render( QPainter *, const QRegion &) method with the dirtyRect as the second parameter.

另请参阅 mainFrame () 和 view ().

void restoreFrameStateRequested (QWebFrame*)

This is the default overload of this signal.

This signal is emitted when the load of frame is finished and the application may now update its state accordingly.

该函数在 Qt 4.5 引入。

void saveFrameStateRequested (QWebFrame*,QWebHistoryItem*)

This is the default overload of this signal.

This signal is emitted shortly before the history of navigated pages in frame is changed, for example when navigating back in the history.

The provided QWebHistoryItem , item , holds the history entry of the frame before the change.

A potential use-case for this signal is to store custom data in the QWebHistoryItem associated to the frame, using QWebHistoryItem.setUserData ().

该函数在 Qt 4.5 引入。

void scrollRequested (int,int,const QRect&)

This is the default overload of this signal.

This signal is emitted whenever the content given by rectToScroll needs to be scrolled dx and dy downwards and no view was set.

另请参阅 view ().

void selectionChanged ()

This is the default overload of this signal.

This signal is emitted whenever the selection changes, either interactively or programmatically (e.g. by calling triggerAction () with a selection action).

另请参阅 selectedText ().

void statusBarMessage (const QString&)

This is the default overload of this signal.

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

void statusBarVisibilityChangeRequested (bool)

This is the default overload of this signal.

This signal is emitted whenever the visibility of the statusbar in a web browser window that hosts QWebPage should be changed to visible .

void toolBarVisibilityChangeRequested (bool)

This is the default overload of this signal.

This signal is emitted whenever the visibility of the toolbar in a web browser window that hosts QWebPage should be changed to visible .

void unsupportedContent (QNetworkReply*)

This is the default overload of this signal.

此信号被发射当 WebKit cannot handle a link the user navigated to or a web server's response includes a "Content-Disposition" header with the 'attachment' directive. If "Content-Disposition" is present in reply , the web server is indicating that the client should prompt the user to save the content regardless of content-type. See RFC 2616 sections 19.5.1 for details about Content-Disposition.

At signal emission time the meta-data of the QNetworkReply reply is available.

注意: The receiving slot is responsible for deleting the QNetworkReply reply .

注意: This signal is only emitted if the forwardUnsupportedContent property is set to true.

另请参阅 downloadRequested ().

void viewportChangeRequested ()

This is the default overload of this signal.

Page authors can provide the supplied values by using the viewport meta tag. More information about this can be found at Safari Reference Library: Using the Viewport Meta Tag .

该函数在 Qt 4.8 引入。

另请参阅 QWebPage.ViewportAttributes , setPreferredContentsSize (), and QGraphicsWebView.setScale ().

void windowCloseRequested ()

This is the default overload of this signal.

This signal is emitted whenever the page requests the web browser window to be closed, for example through the JavaScript window.close() 调用。