CopperSpice API
1.9.2
|
The QWebPage class provides an object to view and edit web documents. More...
Classes | |
class | ChooseMultipleFilesExtensionOption |
Describes the option for the multiple files selection extension More... | |
class | ChooseMultipleFilesExtensionReturn |
Holds the return value for the multiple files selection extension More... | |
class | ErrorPageExtensionOption |
Describes the option for the error page extension More... | |
class | ErrorPageExtensionReturn |
Defines the page which will be shown in a frame where an error occurred More... | |
class | ExtensionOption |
An extended input argument to QWebPage's extension support More... | |
class | ExtensionReturn |
Provides an output result from a QWebPage's extension More... | |
class | ViewportAttributes |
Describes hints that can be applied to a viewport More... | |
Public Typedefs | |
using | FindFlags = QFlags< FindFlag > |
Public Types | |
enum | ErrorDomain |
enum | Extension |
enum | Feature |
enum | FindFlag |
enum | LinkDelegationPolicy |
enum | NavigationType |
enum | PermissionPolicy |
enum | WebAction |
enum | WebWindowType |
Public Slots | |
bool | shouldInterruptJavaScript () |
Public Slots inherited from QObject | |
void | deleteLater () |
Public Methods | |
QWebPage (QObject *parent=nullptr) | |
~QWebPage () | |
QAction * | action (WebAction action) const |
quint64 | bytesReceived () const |
QMenu * | createStandardContextMenu () |
QWebFrame * | currentFrame () const |
bool | event (QEvent *event) override |
virtual bool | extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0) |
bool | findText (const QString &subString, FindFlags options=0) |
bool | focusNextPrevChild (bool next) |
QWebFrame * | frameAt (const QPoint &pos) const |
QWebHistory * | history () const |
QVariant | inputMethodQuery (Qt::InputMethodQuery property) const |
QWebFrame * | mainFrame () const |
QNetworkAccessManager * | networkAccessManager () const |
QWebPluginFactory * | pluginFactory () const |
QSize | preferredContentsSize () const |
void | setActualVisibleContentRect (const QRect &rect) const |
void | setFeaturePermission (QWebFrame *frame, Feature feature, PermissionPolicy policy) |
void | setNetworkAccessManager (QNetworkAccessManager *manager) |
void | setPluginFactory (QWebPluginFactory *factory) |
void | setPreferredContentsSize (const QSize &size) |
QWebSettings * | settings () const |
void | setView (QWidget *view) |
QStringList | supportedContentTypes () const |
bool | supportsContentType (const QString &mimeType) const |
virtual bool | supportsExtension (Extension extension) const |
bool | swallowContextMenuEvent (QContextMenuEvent *event) |
quint64 | totalBytes () const |
virtual void | triggerAction (WebAction action, bool checked=false) |
QUndoStack * | undoStack () const |
void | updatePositionDependentActions (const QPoint &pos) |
QWidget * | view () const |
ViewportAttributes | viewportAttributesForSize (const QSize &availableSize) const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Protected Methods | |
virtual bool | acceptNavigationRequest (QWebFrame *frame, const QNetworkRequest &request, NavigationType type) |
virtual QString | chooseFile (QWebFrame *frame, const QString &suggestedFile) |
virtual QObject * | createPlugin (const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) |
virtual QWebPage * | createWindow (WebWindowType type) |
virtual void | javaScriptAlert (QWebFrame *frame, const QString &msg) |
virtual bool | javaScriptConfirm (QWebFrame *frame, const QString &msg) |
virtual void | javaScriptConsoleMessage (const QString &message, int lineNumber, const QString &sourceID) |
virtual bool | javaScriptPrompt (QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result) |
virtual QString | userAgentForUrl (const QUrl &url) const |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Properties | |
contentEditable | |
forwardUnsupportedContent | |
hasSelection | |
linkDelegationPolicy | |
modified | |
palette | |
preferredContentsSize | |
selectedHtml | |
selectedText | |
viewportSize | |
Properties inherited from QObject | |
objectName | |
Friends | |
class | QGraphicsWebView |
class | QWebFrame |
class | QWebInspector |
class | QWebView |
Related Functions | |
These are not member functions | |
int | qWebKitMajorVersion () |
int | qWebKitMinorVersion () |
QString | qWebKitVersion () |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
Additional Inherited Members | |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
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() in QWebView), triggerAction(), findText() and settings(). More QWebView-like functions can be found in the main frame of QWebPage, obtained via the mainFrame() function. For example, the load(), setUrl() and setHtml() functions for QWebPage can be accessed using QWebFrame.
The 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() signal is emitted 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.
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:
The Thumbnail
's constructor takes in a url. We connect our QWebPage object's loadFinished() signal to our private slot, render()
.
The render()
function shows how we can paint a thumbnail using a QWebPage object.
We begin by setting the viewportSize and then we instantiate a QImage object, 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.
Typedef for QFlags<FindFlag> which contains an OR combination of FindFlag values.
Refer to QWebPage::FindFlag for the enum documentation.
This enum describes the domain of an ErrorPageExtensionOption object, for example the layer in which the error occurred.
Constant | Value | Description |
---|---|---|
QWebPage::QtNetwork | 0 | Error occurred in the QtNetwork layer and is of type QNetworkReply::NetworkError |
QWebPage::Http | 1 | Error occurred in the HTTP layer and it an HTTP status code. |
QWebPage::WebKit | 2 | Error is an internal WebKit error |
enum 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().
Constant | Value | Description |
---|---|---|
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. |
enum QWebPage::Feature |
This enum describes the elements of a web page is has permission to access.
Constant | Value | Description |
---|---|---|
QWebPage::Notifications | 0 | |
QWebPage::Geolocation | 1 |
enum QWebPage::FindFlag |
This enum describes the options available for the findText() method. The options can be OR-ed together from the following list.
Constant | Value | Description |
---|---|---|
QWebPage::FindBackward | 1 | Searches backwards instead of forwards. |
QWebPage::FindCaseSensitively | 2 | By default findText() works case insensitive. Specifying this option changes the behavior 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 enum defines the delegation policies a webpage can have when activating links and emitting the linkClicked() signal.
Constant | Value | Description |
---|---|---|
QWebPage::DontDelegateLinks | 0 | No links are delegated. Instead, QWebPage tries to handle them all. |
QWebPage::DelegateExternalLinks | 1 | When activating links which point to documents not stored on the local file system or the Resource system, then linkClicked() is emitted. |
QWebPage::DelegateAllLinks | 2 | Whenever a link is activated the linkClicked() signal is emitted. |
This enum describes the types of navigation available when browsing through hyperlinked documents.
Constant | Value | Description |
---|---|---|
QWebPage::NavigationTypeLinkClicked | 0 | User clicked on a link or pressed return on a focused link. |
QWebPage::NavigationTypeFormSubmitted | 1 | 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 | User activated the reload action. |
QWebPage::NavigationTypeFormResubmitted | 4 | An HTML form was submitted a second time. |
QWebPage::NavigationTypeOther | 5 | Navigation to another document using a method not listed above. |
This enum
Constant | Value | Description |
---|---|---|
QWebPage::PermissionUnknown | 0 | |
QWebPage::PermissionGrantedByUser | 1 | |
QWebPage::PermissionDeniedByUser | 2 |
enum 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 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.
Constant | Value | Description |
---|---|---|
QWebPage::NoWebAction | -1 | No action is triggered. |
QWebPage::OpenLink | 0 | Open the current link. |
QWebPage::OpenLinkInNewWindow | 1 | Open the current link in a new window. |
QWebPage::OpenFrameInNewWindow | 2 | Replicate the current frame in a new window. |
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 window. |
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 | Stop loading the current page. |
QWebPage::StopScheduledPageRefresh | 67 | Stop all pending page refresh/redirect requests. |
QWebPage::Reload | 11 | Reload the current page. |
QWebPage::ReloadAndBypassCache | 53 | Reload the current page, but do not use any local cache. |
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 | Paste content from the clipboard. |
QWebPage::Undo | 15 | Undo the last editing action. |
QWebPage::Redo | 16 | Redo the last editing action. |
QWebPage::MoveToNextChar | 17 | Move the cursor to the next character. |
QWebPage::MoveToPreviousChar | 18 | Move the cursor to the previous character. |
QWebPage::MoveToNextWord | 19 | Move the cursor to the next word. |
QWebPage::MoveToPreviousWord | 20 | Move the cursor to the previous word. |
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 block. |
QWebPage::MoveToEndOfBlock | 26 | Move the cursor to the end of the block. |
QWebPage::MoveToStartOfDocument | 27 | Move the cursor to the start of the document. |
QWebPage::MoveToEndOfDocument | 28 | Move the cursor to the end of the document. |
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. |
This enum describes the types of window that can be created by the createWindow() function.
Constant | Value | Description |
---|---|---|
QWebPage::WebBrowserWindow | 0 | The window is a regular web browser window. |
QWebPage::WebModalDialog | 1 | The window acts as modal dialog. |
|
explicit |
Constructs an empty QWebPage with the given parent.
QWebPage::~QWebPage | ( | ) |
Destroys the web page.
|
protectedvirtual |
This method is called whenever WebKit wants to display the given request in the specified frame with the navigation type. If the 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.
Returns a QAction for the given action. The action is owned by the QWebPage but you can customize the look by changing its properties. QWebPage also takes care of implementing the action, so that upon triggering the corresponding action is performed on the page.
|
signal |
This signal is emitted whenever the web site is asking to store data to the application cache specified by origin and the defaultOriginQuota allocated to that web site is exceeded.
quint64 QWebPage::bytesReceived | ( | ) | const |
Returns the number of bytes that were received from the network to render the current page.
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 frame.
|
signal |
This signal is emitted whenever the text in form elements changes as well as other editable content.
|
protectedvirtual |
This function is called whenever WebKit encounters an HTML object element with type "application/x-qt-plugin". It is called regardless of the value of QWebSettings::PluginsEnabled. The classid, url, paramNames and paramValues correspond to the HTML object element attributes and child elements to configure the embeddable object.
QMenu * QWebPage::createStandardContextMenu | ( | ) |
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.
|
protectedvirtual |
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.
If the new window can be created, the new window's QWebPage is returned, otherwise a null pointer is returned.
If the view associated with the web page is a QWebView object, then the default implementation forwards the request to QWebView's createWindow() function, otherwise it returns a null pointer.
If type is WebModalDialog, the application must call setWindowModality on the new window.
QWebFrame * QWebPage::currentFrame | ( | ) | const |
Returns the frame currently active.
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.
|
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.
|
overridevirtual |
Reimplemented from QObject::event()
|
virtual |
This method 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 is determined by extension. Returns true if the extension was called successfully, otherwise returns false.
The given option and output values are typically casted to the corresponding types. For example, ChooseMultipleFilesExtensionOption and ChooseMultipleFilesExtensionReturn for ChooseMultipleFilesExtension. You can call supportsExtension() to check if an extension is supported by the page.
|
signal |
A signal which indicates a permission request has been cancelled.
|
signal |
A signal which indicates a permission request has been made.
Finds the specified subString in the current page using the given options. To clear the selection pass an empty string. Returns true if the subString was found, otherwise returns false.
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.
bool QWebPage::focusNextPrevChild | ( | bool | next | ) |
Similar to 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 not.
Returns the frame at the given point pos or a nullptr if there is no frame at that position.
|
signal |
This signal is emitted whenever the page creates a new frame.
|
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.
QWebHistory * QWebPage::history | ( | ) | const |
Returns a pointer to the view's history of navigated web pages.
QVariant QWebPage::inputMethodQuery | ( | Qt::InputMethodQuery | property | ) | const |
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.
The given property specifies which property is queried.
This function is called whenever a JavaScript program running inside frame calls the alert() function with the message msg.
The default implementation shows the message, msg, with QMessageBox::information.
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.
The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
|
protectedvirtual |
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.
|
protectedvirtual |
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 canceled 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 canceled by the user, the implementation should return true and the result string must not be null.
The default implementation uses QInputDialog::getText().
|
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 instead.
|
signal |
This signal is emitted when the mouse hovers over a link.
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.
|
signal |
This signal is emitted when the page finishes loading content. This signal is independent of script execution or page rendering. ok will indicate whether the load was successful or any error occurred.
|
signal |
This signal is emitted when the global progress status changes. The current value is provided by progress and scales from 0 to 100, which is the default range of QProgressBar. It accumulates changes from all the child frames.
|
signal |
This signal is emitted when a page starts loading content.
QWebFrame * QWebPage::mainFrame | ( | ) | const |
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.
|
signal |
This signal is emitted whenever the visibility of the menubar in a web browser window that hosts QWebPage should be changed to visible.
|
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() slot.
QNetworkAccessManager * QWebPage::networkAccessManager | ( | ) | const |
Returns the QNetworkAccessManager that is responsible for serving network requests for this QWebPage.
QWebPluginFactory * QWebPage::pluginFactory | ( | ) | const |
Returns the QWebPluginFactory that is responsible for creating plugins embedded into this QWebPage. If no plugin factory is installed a null pointer is returned.
QSize QWebPage::preferredContentsSize | ( | ) | const |
Returns the value of the property.
|
signal |
This signal is emitted whenever the page requests the web browser to print frame, for example through the JavaScript window.print()
call.
|
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.
|
signal |
This signal is emitted when the load of frame is finished and the application may now update its state accordingly.
|
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().
|
signal |
This signal is emitted whenever the content given by rect needs to be scrolled dx and dy downwards and no view was set.
|
signal |
This signal is emitted whenever the selection changes, either interactively or programmatically (e.g. by calling triggerAction() with a selection action).
void QWebPage::setActualVisibleContentRect | ( | const QRect & | rect | ) | const |
Sets the area for content to the given rect.
void QWebPage::setFeaturePermission | ( | QWebFrame * | frame, |
Feature | feature, | ||
PermissionPolicy | policy | ||
) |
Sets the permission for the website displayed in the given frame using the feature and policy.
void QWebPage::setNetworkAccessManager | ( | QNetworkAccessManager * | manager | ) |
Sets the QNetworkAccessManager manager responsible for serving network requests for this QWebPage.
void QWebPage::setPluginFactory | ( | QWebPluginFactory * | factory | ) |
Sets the QWebPluginFactory factory responsible for creating plugins embedded into this QWebPage. The plugin factory is only used if the QWebSettings::PluginsEnabled attribute is enabled.
void QWebPage::setPreferredContentsSize | ( | const QSize & | size | ) |
Sets the value of the property to size.
QWebSettings * QWebPage::settings | ( | ) | const |
Returns a pointer to the page's settings object.
void QWebPage::setView | ( | QWidget * | view | ) |
Sets the view that is associated with the web page.
|
slot |
This method 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. The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.
|
signal |
This signal is emitted when the statusbar text is changed by the page.
|
signal |
This signal is emitted whenever the visibility of the statusbar in a web browser window that hosts QWebPage should be changed to visible.
QStringList QWebPage::supportedContentTypes | ( | ) | const |
Returns the list of all content types supported by QWebPage.
bool QWebPage::supportsContentType | ( | const QString & | mimeType | ) | const |
Returns true if QWebPage can handle the given mimeType, otherwise returns false.
|
virtual |
This method returns true if the web page supports extension, otherwise false is returned.
bool QWebPage::swallowContextMenuEvent | ( | QContextMenuEvent * | event | ) |
Filters the context menu 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.
|
signal |
This signal is emitted whenever the visibility of the toolbar in a web browser window that hosts QWebPage should be changed to visible.
quint64 QWebPage::totalBytes | ( | ) | const |
Returns the total number of bytes that were received from the network to render the current page, including extra content such as embedded images.
|
virtual |
This method can be called to trigger the specified action. It is also called by CsWebKit if the user triggers the action, for example through a context menu item. If action is a checkable action then checked specified whether the action is toggled or not.
QUndoStack * QWebPage::undoStack | ( | ) | const |
Returns a pointer to the undo stack used for editable content.
|
signal |
This signal is emitted when WebKit can not 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. Refer to RFC 2616 sections 19.5.1 for details about Content-Disposition.
At signal emission time the meta data of the QNetworkReply reply is available.
void QWebPage::updatePositionDependentActions | ( | const 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.
This method 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 parameter.
The default implementation returns the following value:
"Mozilla/5.0 (Platform%Security%Subplatform%) AppleWebKit/WebKitVersion% (KHTML, like Gecko) AppVersion Safari/WebKitVersion%"
On mobile platforms, "Mobile Safari" is used instead of "Safari".
In this string the following values are replaced at runtime:
QWidget * QWebPage::view | ( | ) | const |
Returns the view widget that is associated with the web page.
ViewportAttributes QWebPage::viewportAttributesForSize | ( | const QSize & | availableSize | ) | const |
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.
The 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).
On a 240 DPI screen, 1 DIPs would equal 1.5 physical pixels.
An invalid instance will be returned in the case an empty size is passed to the method.
|
signal |
Page authors can provide the supplied values by using the viewport meta tag. More information about can be found in the Apple Safari Reference Library, Using the Viewport Meta Tag.
|
signal |
This signal is emitted whenever the page requests the web browser window to be closed, for example through the JavaScript window.close()
call.
|
related |
Returns the 'major' version number of WebKit at runtime as an integer (for example, 531). This is the version of WebKit the application was compiled against.
|
related |
Returns the 'minor' version number of WebKit at runtime as an integer (for example, 3). This is the version of WebKit the application was compiled against.
|
related |
Returns the version number of WebKit at runtime as a string (for example, "531.3"). This version is commonly used in WebKit based browsers as part of the user agent string. Web servers and JavaScript might use it to identify the presence of certain WebKit engine features and behavior. The evolution of this version is bound to the releases of Apple's Safari browser.
|
This property holds whether the content in this QWebPage is editable or not. If this property is enabled the contents of the page can be edited by the user through a visible cursor. If disabled (the default) only HTML elements in the web page with their contenteditable
attribute set are editable.
Properties | Class Methods |
---|---|
read | isContentEditable |
write | setContentEditable |
|
This property holds whether QWebPage should forward unsupported content. If enabled, the unsupportedContent() signal is emitted with a network reply that can be used to read the content. If disabled the download of such content is aborted immediatel and unsupported content is not forwarded.
Properties | Class Methods |
---|---|
read | forwardUnsupportedContent |
write | setForwardUnsupportedContent |
|
This property holds whether this page contains selected content or not.
Properties | Class Methods |
---|---|
read | hasSelection |
|
This property holds how QWebPage should delegate the handling of links through the linkClicked() signal.
The default is to delegate no links.
Properties | Class Methods |
---|---|
read | linkDelegationPolicy |
write | setLinkDelegationPolicy |
|
This property holds whether the page contains unsubmitted form data, or the contents have been changed.
By default, this property is false.
Properties | Class Methods |
---|---|
read | isModified |
|
This property holds the page's palette. The base brush of the palette is used to draw the background of the main frame.
By default, this property contains the application's default palette.
Properties | Class Methods |
---|---|
read | palette |
write | setPalette |
|
This property holds a custom size used for laying out the page contents. If this property is set to a valid size, this size is used for all layout needs instead of the size of the viewport. Setting an invalid size, makes the page fall back to using the viewport size for layout.
By default all pages are laid out using the viewport of the page as the base.
As pages mostly are designed for desktop usage, they often do not layout properly on small devices as the contents require a certain view width. For this reason it is common to use a different layout size and then scale the contents to fit within the actual view.
Properties | Class Methods |
---|---|
read | preferredContentsSize |
write | setPreferredContentsSize |
|
This property holds the HTML currently selected.
By default, this property contains an empty string.
Properties | Class Methods |
---|---|
read | selectedHtml |
|
This property holds the text currently selected.
By default, this property contains an empty string.
Properties | Class Methods |
---|---|
read | selectedText |
|
This property holds the size of the viewport.
The size affects for example the visibility of scrollbars if the document is larger than the viewport.
By default, for a newly-created Web page, this property contains a size with zero width and height.
Properties | Class Methods |
---|---|
read | viewportSize |
write | setViewportSize |