IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QWebEnginePage Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QWebEnginePage Class▲

  • Header: QWebEnginePage

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)

    target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)

  • qmake: QT += webenginecore

  • Inherits: https://

Detailed Description▲

A web engine page holds the contents of an HTML document, the history of navigated links, and actions.

https://'s API is very similar to https://, as you are still provided with common functions like https://() (known as https://() in https://), https://(), and https://().

A page can be loaded using https://() or https://(). Alternatively, if you have the HTML content readily available, you can use https://(). The GET method is always used to load URLs.

The https:// class also offers methods to retrieve both the URL currently loaded by the page (see https://()) as well as the URL originally requested to be loaded (see https://()). These methods make possible the retrieval of the URL before and after a DNS resolution or a redirection occurs during the load process. The https://() also matches to the URL added to the page history (https://) if load is successful.

The title of an HTML page can be accessed with the https://() property. Additionally, a page may also specify an icon, which can be accessed using the https://() or its URL using the https://() property. If the title or the icon changes, the corresponding https://(), https://() and https://() signals will be emitted. The https://() property enables zooming the contents of the web page by a scale factor.

The https://() signal is emitted when the page begins to load, whereas the https://() signal is emitted whenever an element of the web page completes loading, such as an embedded image or a script. The https://() signal is emitted when the page contents have been loaded completely, independent of script execution or page rendering. Its argument, either true or false, indicates whether or not the load operation succeeded.

An HTML document is loaded in a main frame within the web page. If it references child frames (as defined by the <frame> or <iframe> elements), they are considered part of the content. Child frames are individually accessible only through JavaScript.

Web sites define security origin for safely accessing each other's resources for client-side scripting or databases. An origin consist of a host name, a scheme, and a port number. For example, the sites http://www.example.com/my/page.html and http://www.example.com/my/overview.html are allowed to share the same database or access each other's documents when used in HTML frame sets and JavaScript. At the same time, http://www.malicious.com/evil.html is prevented from accessing the resources of http://www.example.com/, because they are of a different security origin. By default, local schemes like file:// and qrc:// are considered to be in the same security origin, and can access each other's resources. Local resources are by default restricted from accessing remote content, which means that file:// will not be able to access http://domain.com/foo.html.

Scripts can be executed on the web page by using https://(), either in the main JavaScript world, along with the rest of the JavaScript coming from the web contents, or in their own isolated world. While the DOM of the page can be accessed from any world, JavaScript variables of a function defined in one world are not accessible from a different one. https:// provides some predefined IDs for this purpose. Using the runJavaScript() version without the world ID is the same as running the script in the MainWorld.

The https:// setting can be used to make the view associated with the page automatically receive focus when a navigation operation occurs (like loading or reloading a page or navigating through history).

Member Type Documentation▲

 

enum QWebEnginePage::Feature▲

This enum describes the platform feature access categories that the user may be asked to grant or deny access to:

Constant

Value

Description

https://::Notifications

0

Web notifications for the end-user.

https://::Geolocation

1

Location hardware or service.

https://::MediaAudioCapture

2

Audio capture devices, such as microphones.

https://::MediaVideoCapture

3

Video devices, such as cameras.

https://::MediaAudioVideoCapture

4

Both audio and video capture devices.

https://::MouseLock

5

Mouse locking, which locks the mouse pointer to the web view and is typically used in games.

https://::DesktopVideoCapture (since Qt 5.10)

6

Video output capture, that is, the capture of the user's display, for screen sharing purposes for example.

https://::DesktopAudioVideoCapture (since Qt 5.10)

7

Both audio and video output capture.

See Also▲

See also https://(), https://(), https://(), https://

enum QWebEnginePage::FileSelectionMode▲

This enum indicates whether the implementation of the https://() function should return only one file or may return multiple files:

Constant

Value

Description

https://::FileSelectOpen

0

Return only one file name.

https://::FileSelectOpenMultiple

1

Return multiple file names.

https://::FileSelectUploadFolder

2

Allows users to specify a single existing folder for upload.

https://::FileSelectSave

3

Specify a new file to be created.

See Also▲

See also https://()

enum QWebEnginePage::FindFlag▲

flags QWebEnginePage::FindFlags

This enum describes the options available to the https://() function. The options can be OR-ed together from the following list:

Constant

Value

Description

https://::FindBackward

1

Searches backwards instead of forwards.

https://::FindCaseSensitively

2

By default https://() works case insensitive. Specifying this option changes the behavior to a case sensitive find operation.

The FindFlags type is a typedef for https://<FindFlag>. It stores an OR combination of FindFlag values.

enum QWebEnginePage::JavaScriptConsoleMessageLevel▲

This enum describes the different severity levels a JavaScript console message can have:

Constant

Value

Description

https://::InfoMessageLevel

0

The message is purely informative and can safely be ignored.

https://::WarningMessageLevel

1

The message informs about unexpected behavior or errors that may need attention.

https://::ErrorMessageLevel

2

The message indicates there has been an error.

enum QWebEnginePage::LifecycleState▲

This enum describes the lifecycle state of the page:

Constant

Value

Description

https://::LifecycleState::Active

0

Normal state.

https://::LifecycleState::Frozen

1

Low CPU usage state where most HTML task sources are suspended.

https://::LifecycleState::Discarded

2

Very low resource usage state where the entire browsing context is discarded.

See Also▲

See also https://, https://, https://

enum QWebEnginePage::NavigationType▲

Constant

Value

Description

https://::NavigationTypeLinkClicked

0

The navigation request resulted from a clicked link.

https://::NavigationTypeTyped

1

The navigation request resulted from an explicitly loaded URL.

https://::NavigationTypeFormSubmitted

2

The navigation request resulted from a form submission.

https://::NavigationTypeBackForward

3

The navigation request resulted from a back or forward action.

https://::NavigationTypeReload

4

The navigation request resulted from a reload action.

https://::NavigationTypeRedirect (since Qt 5.14)

6

The navigation request resulted from a content or server controlled redirect. This also includes automatic reloads.

https://::NavigationTypeOther

5

The navigation request was triggered by other means not covered by the above.

See Also▲

See also https://()

enum QWebEnginePage::PermissionPolicy▲

This enum describes the permission policies that the user may set for data or device access:

Constant

Value

Description

https://::PermissionUnknown

0

It is unknown whether the user grants or denies permission.

https://::PermissionGrantedByUser

1

The user has granted permission.

https://::PermissionDeniedByUser

2

The user has denied permission.

See Also▲

See also https://(), https://(), https://(), https://

enum QWebEnginePage::RenderProcessTerminationStatus▲

This enum describes the status with which the render process terminated:

Constant

Value

Description

https://::NormalTerminationStatus

0

The render process terminated normally.

https://::AbnormalTerminationStatus

1

The render process terminated with with a non-zero exit status.

https://::CrashedTerminationStatus

2

The render process crashed, for example because of a segmentation fault.

https://::KilledTerminationStatus

3

The render process was killed, for example by SIGKILL or task manager kill.

enum QWebEnginePage::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 https://() on the action returned by https://().

Constant

Value

Description

https://::NoWebAction

- 1

No action is triggered.

https://::Back

0

Navigate back in the history of navigated links.

https://::Forward

1

Navigate forward in the history of navigated links.

https://::Stop

2

Stop loading the current page.

https://::Reload

3

Reload the current page.

https://::ReloadAndBypassCache

10

Reload the current page, but do not use any local cache.

https://::Cut

4

Cut the content currently selected into the clipboard.

https://::Copy

5

Copy the content currently selected into the clipboard.

https://::Paste

6

Paste content from the clipboard.

https://::Undo

7

Undo the last editing action.

https://::Redo

8

Redo the last editing action.

https://::SelectAll

9

Select all content. This action is only enabled when the page's content is focused. The focus can be forced by the JavaScript window.focus() call, or the https:// setting should be enabled to get automatic focus.

https://::PasteAndMatchStyle

11

Paste content from the clipboard with current style.

https://::OpenLinkInThisWindow (since Qt 5.6)

12

Open the current link in the current window.

https://::OpenLinkInNewWindow (since Qt 5.6)

13

Open the current link in a new window. Requires implementation of https://() or https://().

https://::OpenLinkInNewTab (since Qt 5.6)

14

Open the current link in a new tab. Requires implementation of https://() or https://().

https://::OpenLinkInNewBackgroundTab (since Qt 5.7)

31

Open the current link in a new background tab. Requires implementation of https://() or https://().

https://::CopyLinkToClipboard (since Qt 5.6)

15

Copy the current link to the clipboard.

https://::CopyImageToClipboard (since Qt 5.6)

17

Copy the clicked image to the clipboard.

https://::CopyImageUrlToClipboard (since Qt 5.6)

18

Copy the clicked image's URL to the clipboard.

https://::CopyMediaUrlToClipboard (since Qt 5.6)

20

Copy the hovered audio or video's URL to the clipboard.

https://::ToggleMediaControls (since Qt 5.6)

21

Toggle between showing and hiding the controls for the hovered audio or video element.

https://::ToggleMediaLoop (since Qt 5.6)

22

Toggle whether the hovered audio or video should loop on completetion or not.

https://::ToggleMediaPlayPause (since Qt 5.6)

23

Toggle the play/pause state of the hovered audio or video element.

https://::ToggleMediaMute (since Qt 5.6)

24

Mute or unmute the hovered audio or video element.

https://::DownloadLinkToDisk (since Qt 5.6)

16

Download the current link to the disk. Requires a slot for https://().

https://::DownloadImageToDisk (since Qt 5.6)

19

Download the highlighted image to the disk. Requires a slot for https://().

https://::DownloadMediaToDisk (since Qt 5.6)

25

Download the hovered audio or video to the disk. Requires a slot for https://().

https://::InspectElement (since Qt 5.6)

26

Trigger any attached Web Inspector to inspect the highlighed element.

https://::ExitFullScreen (since Qt 5.6)

27

Exit the fullscreen mode.

https://::RequestClose (since Qt 5.6)

28

Request to close the web page. If defined, the window.onbeforeunload handler is run, and the user can confirm or reject to close the page. If the close request is confirmed, windowCloseRequested is emitted.

https://::Unselect (since Qt 5.7)

29

Clear the current selection.

https://::SavePage (since Qt 5.7)

30

Save the current page to disk. MHTML is the default format that is used to store the web page on disk. Requires a slot for https://().

https://::ViewSource (since Qt 5.8)

32

Show the source of the current page in a new tab. Requires implementation of https://() or https://().

https://::ToggleBold (since Qt 5.10)

33

Toggles boldness for the selection or at the cursor position. Requires contenteditable="true".

https://::ToggleItalic (since Qt 5.10)

34

Toggles italics for the selection or at the cursor position. Requires contenteditable="true".

https://::ToggleUnderline (since Qt 5.10)

35

Toggles underlining of the selection or at the cursor position. Requires contenteditable="true".

https://::ToggleStrikethrough (since Qt 5.10)

36

Toggles striking through the selection or at the cursor position. Requires contenteditable="true".

https://::AlignLeft (since Qt 5.10)

37

Aligns the lines containing the selection or the cursor to the left. Requires contenteditable="true".

https://::AlignCenter (since Qt 5.10)

38

Aligns the lines containing the selection or the cursor at the center. Requires contenteditable="true".

https://::AlignRight (since Qt 5.10)

39

Aligns the lines containing the selection or the cursor to the right. Requires contenteditable="true".

https://::AlignJustified (since Qt 5.10)

40

Stretches the lines containing the selection or the cursor so that each line has equal width. Requires contenteditable="true".

https://::Indent (since Qt 5.10)

41

Indents the lines containing the selection or the cursor. Requires contenteditable="true".

https://::Outdent (since Qt 5.10)

42

Outdents the lines containing the selection or the cursor. Requires contenteditable="true".

https://::InsertOrderedList (since Qt 5.10)

43

Inserts an ordered list at the current cursor position, deleting the current selection. Requires contenteditable="true".

https://::InsertUnorderedList (since Qt 5.10)

44

Inserts an unordered list at the current cursor position, deleting the current selection. Requires contenteditable="true".

https://::ChangeTextDirectionLTR (since Qt 6.6)

45

Changes text direction to left-to-right in the focused input element.

https://::ChangeTextDirectionRTL (since Qt 6.6)

46

Changes text direction to right-to-left in the focused input element.

enum QWebEnginePage::WebWindowType▲

This enum describes the types of window that can be created by the https://() function:

Constant

Value

Description

https://::WebBrowserWindow

0

A complete web browser window.

https://::WebBrowserTab

1

A web browser tab.

https://::WebDialog

2

A window without decoration.

https://::WebBrowserBackgroundTab (since Qt 5.7)

3

A web browser tab without hiding the current visible https://.

Property Documentation▲

 

audioMuted : bool▲

This property holds whether the current page audio is muted.

The default value is false.

Access functions:

  • bool isAudioMuted() const

  • void setAudioMuted(bool muted)

Notifier signal:

  • void https://(bool muted)

See Also▲

See also https://

backgroundColor : QColor▲

This property holds the page's background color behind the document's body.

You can set the background color to https:// or to a translucent color to see through the document, or you can set it to match your web content in a hybrid application to prevent the white flashes that may appear during loading.

The default value is white.

Access functions:

  • backgroundColor() const

  • void setBackgroundColor(const &color)

[read-only] contentsSize : const QSizeF▲

This property holds the size of the page contents.

Access functions:

  • contentsSize() const

Notifier signal:

  • void contentsSizeChanged(const &size)

[read-only] hasSelection : const bool▲

This property holds whether this page contains selected content or not.

Access functions:

  • bool hasSelection() const

See Also▲

See also https://()

[read-only] icon : const QIcon▲

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

By default, this property contains a null icon. If touch icons are disabled (see QWebEngineSettings::TouchIconsEnabled), the favicon is provided in two sizes (16x16 and 32x32 pixels) encapsulated in QIcon. Otherwise, single icon is provided with the largest available size.

Access functions:

  • icon() const

Notifier signal:

  • void https://(const &icon)

See Also▲

See also https://(), https://(), https://(), https://

[read-only] iconUrl : const QUrl▲

This property holds the URL of the icon associated with the page currently viewed.

By default, this property contains an empty URL.

Access functions:

  • iconUrl() const

Notifier signal:

  • void https://(const &url)

See Also▲

See also https://(), https://(), https://()

lifecycleState : LifecycleState▲

This property holds the current lifecycle state of the page.

The following restrictions are enforced by the setter:

  • A https:// page must remain in the Active state.

  • If the page is being inspected by a https:// then both pages must remain in the Active states.

  • A page in the Discarded state can only transition to the Active state. This will cause a reload of the page.

These are the only hard limits on the lifecycle state, but see also https:// for the recommended soft limits.

Access functions:

  • lifecycleState() const

  • void setLifecycleState( state)

Notifier signal:

  • void lifecycleStateChanged( state)

See Also▲

See also https://, https://, https://

[read-only, since 6.2] loading : const bool▲

This property holds whether the page is currently loading.

This property was introduced in Qt 6.2.

Access functions:

  • bool isLoading() const

Notifier signal:

  • void https://(const &loadingInfo)

See Also▲

See also https://, https://, https://

[read-only] recentlyAudible : const bool▲

This property holds the current page's audible state, that is, whether audio was recently played or not.

The default value is false.

Access functions:

  • bool recentlyAudible() const

Notifier signal:

  • void https://(bool recentlyAudible)

See Also▲

See also https://

[read-only] recommendedState : const LifecycleState▲

This property holds the recommended limit for the lifecycle state of the page.

Setting the lifecycle state to a lower resource usage state than the recommended state may cause side-effects such as stopping background audio playback or loss of HTML form input. Setting the lifecycle state to a higher resource state is however completely safe.

Access functions:

  • recommendedState() const

Notifier signal:

  • void recommendedStateChanged( state)

See Also▲

See also https://, https://, https://

[read-only] renderProcessPid : const qint64▲

This property holds the process ID (PID) of the render process assigned to the current page's main frame.

If no render process is available yet, 0 is returned.

Access functions:

  • renderProcessPid() const

Notifier signal:

  • void https://( pid)

[read-only] requestedUrl : const QUrl▲

This property holds the URL that was originally requested to be loaded by the page that is currently viewed.

The URL may differ from the one returned by https://(), which is the actual URL that results from DNS resolution or redirection.

Access functions:

  • requestedUrl() const

See Also▲

See also https://(), https://()

[read-only] scrollPosition : const QPointF▲

This property holds the scroll position of the page contents.

Access functions:

  • scrollPosition() const

Notifier signal:

  • void scrollPositionChanged(const &position)

[read-only] selectedText : const QString▲

This property holds the text currently selected.

By default, this property contains an empty string.

Access functions:

  • selectedText() const

See Also▲

See also https://()

[read-only] title : const QString▲

This property holds the title of the page as defined by the HTML <title> element.

If the page has no <title> element, then the URL is used instead. For file:// URLs only the filename is used and not the full path.

By default, before any content has been loaded, this property contains an empty string.

Access functions:

  • title() const

See Also▲

See also https://()

url : QUrl▲

This property holds the URL of the page currently viewed.

Setting this property clears the view and loads the URL.

By default, this property contains an empty, invalid URL.

Access functions:

  • url() const

  • void setUrl(const &url)

Notifier signal:

  • void https://(const &url)

See Also▲

See also https://()

visible : bool▲

This property holds whether the page is considered visible in the Page Visibility API.

Setting this property changes the Document.hidden and the Document.visibilityState properties in JavaScript which web sites can use to voluntarily reduce their resource usage if they are not visible to the user.

If the page is connected to a view then this property will be managed automatically by the view according to it's own visibility.

Access functions:

  • bool isVisible() const

  • void setVisible(bool visible)

Notifier signal:

  • void visibleChanged(bool visible)

See Also▲

See also https://

zoomFactor : qreal▲

This property holds the zoom factor for the page content.

Valid values are within the range from 0.25 to 5.0. The default factor is 1.0.

Access functions:

  • zoomFactor() const

  • void setZoomFactor( factor)

Member Function Documentation▲

 

void QWebEnginePage::runJavaScript(const QString &scriptSource, const std::function<void (const QVariant &)> &resultCallback)▲

void QWebEnginePage::runJavaScript(const QString &scriptSource, quint32 worldId = 0, const std::function<void (const QVariant &)> &resultCallback = {})

Runs the JavaScript code contained in scriptSource without checking whether the DOM of the page has been constructed. If you need more control over how the script is run, consider using https://() instead.

To avoid conflicts with other scripts executed on the page, the world in which the script is run is specified by worldId. The world ID values are the same as provided by https://, and between 0 and 256. If you leave out the world ID, the script is run in the MainWorld.

When the script has been executed, resultCallback is called with the result of the last executed statement. resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a https:// parameter. For example:

 
Sélectionnez
page.runJavaScript("document.title", [](const QVariant &amp;v) { qDebug() &lt;&lt; v.toString(); });

Only plain data can be returned from JavaScript as the result value. Supported data types include all of the JSON data types as well as, for example, Date and ArrayBuffer. Unsupported data types include, for example, Function and Promise.

Do not execute lengthy routines in the callback function, because it might block the rendering of the web engine page.

We guarantee that the callback (resultCallback) is always called, but it might be done during page destruction. When https:// is deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding https:// or https:// instance inside it.

See Also▲

See also https://(), https://, https://

[explicit] QWebEnginePage::QWebEnginePage(QObject *parent = nullptr)▲

Constructs an empty https:// with the parent parent.

QWebEnginePage::QWebEnginePage(QWebEngineProfile *profile, QObject *parent = nullptr)▲

Constructs an empty web engine page in the web engine profile profile with the parent parent.

If the profile is not the default profile, the caller must ensure that the profile stays alive for as long as the page does.

[virtual] QWebEnginePage::~QWebEnginePage()▲

Destroys the web page.

[virtual protected] bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)▲

This function is called upon receiving a request to navigate to the specified url by means of the specified navigation type type. isMainFrame indicates whether the request corresponds to the main frame or a child frame. If the function returns true, the navigation request is accepted and url is loaded. The default implementation accepts all navigation requests.

Navigation requests can be delegated to the Qt application instead of having the HTML handler engine process them by overloading this function. This is necessary when an HTML document is used as part of the user interface, and not to display external data, for example, when displaying a list of results.

This function is not called for fragment navigation on the same page. Such navigation, for example, happens by clicking a link to a '#fragment' within the page. It does not trigger a load to a different document, even though it changes page's url and adds history entry. It only serves as a shortcut to scroll within the page. Hence, no delegation of this navigation type is expected to happen.

The loading process is started and the https://() signal is emitted before the request is accepted or rejected. Therefore, a https://() signal that returns false is to be expected even after delegating the request.

When using https:// or https:// with relative links, make sure to specify a base url, otherwise the links will be considered invalid and no navigation requests will be emitted.

The https:// class offers further options for intercepting and manipulating requests.

QAction *QWebEnginePage::action(QWebEnginePage::WebAction action) const▲

Returns a https:// for the specified https:// action.

The action is owned by the https:// but you can customize the look by changing its properties.

QWebEnginePage::action(WebAction action) does not have a default styled icon. Use https://() to have an action with a default styled icon.

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

See Also▲

See also https://()

void QWebEnginePage::audioMutedChanged(bool muted)▲

This signal is emitted when the page's muted state changes.

Not to be confused with a specific HTML5 audio or video element being muted.

Notifier signal for property https://.

void QWebEnginePage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator)▲

This signal is emitted when access to requestUrl requires authentication. authenticator should be used to pass the user name and password for the connection.

void QWebEnginePage::certificateError(const QWebEngineCertificateError &certificateError)▲

This signal is emitted when an invalid certificate error is raised while loading a given request.

The certificateError parameter contains information about the certificate and details of the error, it also provides the way to ignore the error and complete the request or stop loading the request.

See Also▲

See also https://

[virtual protected] QStringList QWebEnginePage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)▲

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 an HTML form.

mode indicates whether only one file or multiple files are expected to be returned.

A suggested filename may be provided as the first entry of oldFiles. acceptedMimeTypes is ignored by the default implementation, but might be used by overrides.

[virtual protected] QWebEnginePage *QWebEnginePage::createWindow(QWebEnginePage::WebWindowType type)▲

This function is called to create a new window of the specified 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 https:// is returned; otherwise a null pointer is returned.

If the view associated with the web page is a https:// object, then the default implementation forwards the request to https://(); otherwise it returns a null pointer.

If this call is not implemented or does not return a new page, https://() is emitted to handle the request.

In the cases when the window creation is being triggered by JavaScript, apart from reimplementing this method the application must also set https:// to true in order for the method to get called.

See Also▲

See also https://(), https://()

[since 6.6] QString QWebEnginePage::devToolsId() const▲

Returns the id of the developer tools host associated with this page.

If remote debugging is enabled (see https://), the id can be used to build the URL to connect to the developer tool websocket: ws://localhost:<debugggin-port>/devtools/page/<id>). The websocket can be used to to interact with the page using the https://.

This function was introduced in Qt 6.6.

QWebEnginePage *QWebEnginePage::devToolsPage() const▲

Returns the page that is hosting the developer tools of this page, if any.

Returns nullptr if no developer tools page is set.

See Also▲

See also https://(), https://()

void QWebEnginePage::download(const QUrl &url, const QString &filename = QString())▲

Downloads the resource from the location given by url to a local file.

If filename is given, it is used as the suggested file name. If it is relative, the file is saved in the standard download location with the given name. If it is a null or empty https://, the default file name is used.

This will emit https://() after the download has started.

[override virtual] bool QWebEnginePage::event(QEvent *e)▲

Reimplements: https://.

void QWebEnginePage::featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature)▲

This signal is emitted when the web site identified by securityOrigin cancels a previously issued request to make use of feature.

See Also▲

See also https://(), https://()

void QWebEnginePage::featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature)▲

This signal is emitted when the web site identified by securityOrigin requests to make use of the resource or device identified by feature.

See Also▲

See also https://(), https://()

[since 6.4] void QWebEnginePage::fileSystemAccessRequested(QWebEngineFileSystemAccessRequest request)▲

This signal is emitted when the web page requests access to local files or directories.

The request object request can be used to accept or reject the request.

This function was introduced in Qt 6.4.

void QWebEnginePage::findText(const QString &subString, QWebEnginePage::FindFlags options = {}, const std::function<void (const QWebEngineFindTextResult &)> &resultCallback = ...)▲

Finds the specified string, subString, in the page, using the given options. The https://() signal is emitted when a string search is completed.

To clear the search highlight, just pass an empty string.

The resultCallback must take a https:// parameter.

We guarantee that the callback (resultCallback) is always called, but it might be done during page destruction. When https:// is deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding https:// or https:// instance inside it.

For example:

 
Sélectionnez
    m_view-&gt;page()-&gt;findText(QStringLiteral("Qt"), QWebEnginePage::FindFlags(), [this](const QWebEngineFindTextResult &amp;result) {
        if (result.numberOfMatches() == 0) QMessageBox::information(m_view, QString(), QStringLiteral("No occurrences found"));
    });
See Also▲

See also https://()

void QWebEnginePage::findTextFinished(const QWebEngineFindTextResult &result)▲

This signal is emitted when a search string search on a page is completed. result is the result of the string search.

See Also▲

See also https://()

void QWebEnginePage::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest)▲

This signal is emitted when the web page issues the request to enter fullscreen mode for a web-element, usually a video element.

The request object fullScreenRequest can be used to accept or reject the request.

If the request is accepted the element requesting fullscreen will fill the viewport, but it is up to the application to make the view fullscreen or move the page to a view that is fullscreen.

See Also▲

See also https://

void QWebEnginePage::geometryChangeRequested(const QRect &geom)▲

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.

https://() expects a size excluding the window decoration, while geom includes it. You have to remove the size of the frame margins from geom to handle this signal correctly.

 
Sélectionnez
window-&gt;setGeometry(geom.marginsRemoved(window-&gt;frameMargins()));

QWebEngineHistory *QWebEnginePage::history() const▲

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

void QWebEnginePage::iconChanged(const QIcon &icon)▲

This signal is emitted when the icon ("favicon") associated with the page is changed. The new icon is specified by icon.

Notifier signal for property https://.

See Also▲

See also https://(), https://(), https://()

void QWebEnginePage::iconUrlChanged(const QUrl &url)▲

This signal is emitted when the URL of the icon ("favicon") associated with the page is changed. The new URL is specified by url.

Notifier signal for property https://.

See Also▲

See also https://(), https://(), https://()

QWebEnginePage *QWebEnginePage::inspectedPage() const▲

Returns the page this page is inspecting, if any.

Returns nullptr if this page is not a developer tools page.

See Also▲

See also https://(), https://()

[virtual protected] void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)▲

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

The default implementation shows the message, msg, with https://.

[virtual protected] bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)▲

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

It is also called when the onbeforeunload handler is requesting a confirmation before leaving a page.

The default implementation executes the query using https:// with https:// and https:// buttons.

[virtual protected] void QWebEnginePage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)▲

This function is called when a JavaScript program tries to print the 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.

level indicates the severity of the event that triggered the message. That is, whether it was triggered by an error or a less severe event.

Since Qt 5.6, the default implementation logs the messages in a js https://.

See Also▲

See also https://

[virtual protected] bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result)▲

This function is called whenever a JavaScript program running in a frame affiliated with securityOrigin 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.

The default implementation uses https://().

void QWebEnginePage::linkHovered(const QString &url)▲

This signal is emitted when the mouse hovers over a link. url contains the target URL of the link.

void QWebEnginePage::load(const QUrl &url)▲

Loads url into this page.

The view remains the same until enough data has arrived to display the new URL.

See Also▲

See also https://(), https://(), https://()

void QWebEnginePage::load(const QWebEngineHttpRequest &request)▲

Issues the specified request and loads the response.

See Also▲

See also https://(), https://(), https://(), https://(), https://()

void QWebEnginePage::loadFinished(bool ok)▲

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.

Navigation requests can be delegated to the Qt application instead of having the HTML handler engine process them by overloading the https://() function. Because the loading process is started and the https://() signal is emitted before the request is accepted or rejected, a loadFinished() signal that returns false is to be expected even after delegating the request.

See Also▲

See also https://(), https://()

void QWebEnginePage::loadProgress(int progress)▲

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 https://. It accumulates changes from all the child frames.

void QWebEnginePage::loadStarted()▲

This signal is emitted when a page starts loading content.

See Also▲

See also https://(), https://()

[since 6.2] void QWebEnginePage::loadingChanged(const QWebEngineLoadingInfo &loadingInfo)▲

This signal is emitted when loading the page specified by loadingInfo begins, ends, or fails.

Notifier signal for property https://.

This function was introduced in Qt 6.2.

[since 6.2] void QWebEnginePage::navigationRequested(QWebEngineNavigationRequest &request)▲

This function was introduced in Qt 6.2.

See Also▲

See also https://()

[since 6.2] void QWebEnginePage::newWindowRequested(QWebEngineNewWindowRequest &request)▲

This signal is emitted when request is issued to load a page in a separate web engine window. This can either be because the current page requested it explicitly through a JavaScript call to window.open, or because the user clicked on a link while holding Shift, Ctrl, or a built-in combination that triggers the page to open in a new window.

The signal is handled by calling openIn() with the new page on the request. If this signal is not handled, the requested load will fail.

This signal is not emitted if https://() handled the request first.

This function was introduced in Qt 6.2.

See Also▲

See also https://(), https://()

void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success)▲

This signal is emitted when printing the web page into a PDF file has finished. filePath will contain the path the file was requested to be created at, and success will be true if the file was successfully created and false otherwise.

See Also▲

See also https://()

void QWebEnginePage::printRequested()▲

This signal is emitted when the JavaScript window.print() method is called or the user pressed the print button of PDF viewer plugin. Typically, the signal handler can simply call https://().

See Also▲

See also https://()

void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()), const QPageRanges &ranges = {})▲

Renders the current content of the page into a PDF document and saves it in the location specified in filePath. The page size and orientation of the produced PDF document are taken from the values specified in layout, while the range of pages printed is taken from ranges with the default being printing all pages.

This method issues an asynchronous request for printing the web page into a PDF and returns immediately. To be informed about the result of the request, connect to the signal https://().

The https:// web action can be used to interrupt this asynchronous operation.

If a file already exists at the provided file path, it will be overwritten.

See Also▲

See also https://()

void QWebEnginePage::printToPdf(const std::function<void (const QByteArray &)> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()), const QPageRanges &ranges = {})▲

Renders the current content of the page into a PDF document and returns a byte array containing the PDF data as parameter to resultCallback. The page size and orientation of the produced PDF document are taken from the values specified in layout, while the range of pages printed is taken from ranges with the default being printing all pages.

The resultCallback must take a const reference to a https:// as parameter. If printing was successful, this byte array will contain the PDF data, otherwise, the byte array will be empty.

The https:// web action can be used to interrupt this operation.

We guarantee that the callback (resultCallback) is always called, but it might be done during page destruction. When https:// is deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding https:// or https:// instance inside it.

QWebEngineProfile *QWebEnginePage::profile() const▲

Returns the web engine profile the page belongs to.

void QWebEnginePage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost)▲

This signal is emitted when access to requestUrl via proxyHost requires authentication for the proxy. authenticator should be used to pass the user name and password for the connection.

void QWebEnginePage::recentlyAudibleChanged(bool recentlyAudible)▲

This signal is emitted when the page's audible state, recentlyAudible, changes, because the audio is played or stopped.

The signal is also emitted when calling the https://() method.

Notifier signal for property https://.

void QWebEnginePage::registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request)▲

This signal is emitted when the web page tries to register a custom protocol using the https:// API.

The request object request can be used to accept or reject the request:

 
Sélectionnez
void WebView::handleRegisterProtocolHandlerRequested(
        QWebEngineRegisterProtocolHandlerRequest request)
{
    auto answer = QMessageBox::question(window(), tr("Permission Request"),
                                        tr("Allow %1 to open all %2 links?")
                                                .arg(request.origin().host())
                                                .arg(request.scheme()));
    if (answer == QMessageBox::Yes)
        request.accept();
    else
        request.reject();
}

void QWebEnginePage::renderProcessPidChanged(qint64 pid)▲

This signal is emitted when the underlying render process PID, pid, changes.

Notifier signal for property https://.

void QWebEnginePage::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)▲

This signal is emitted when the render process is terminated with a non-zero exit status. terminationStatus is the termination status of the process and exitCode is the status code with which the process terminated.

void QWebEnginePage::replaceMisspelledWord(const QString &replacement)▲

Replace the current misspelled word with replacement.

The current misspelled word can be found in https://(), and suggested replacements in https://().

void QWebEnginePage::save(const QString &filePath, QWebEngineDownloadRequest::SavePageFormat format = QWebEngineDownloadRequest::MimeHtmlSaveFormat) const▲

Save the currently loaded web page to disk.

The web page is saved to filePath in the specified format.

This is a short cut for the following actions:

  • Trigger the Save web action.

  • Accept the next download item and set the specified file path and save format.

This function issues an asynchronous download request for the web page and returns immediately.

See Also▲

See also https://

QWebEngineScriptCollection &QWebEnginePage::scripts()▲

Returns the collection of scripts that are injected into the page.

In addition, a page might also execute scripts added through https://().

See Also▲

See also https://, https://, https://

void QWebEnginePage::selectClientCertificate(QWebEngineClientCertificateSelection clientCertificateSelection)▲

This signal is emitted when a web site requests an SSL client certificate, and one or more were found in system's client certificate store.

Handling the signal is asynchronous, and loading will be waiting until a certificate is selected, or the last copy of clientCertificateSelection is destroyed.

If the signal is not handled, clientCertificateSelection is automatically destroyed, and loading will continue without a client certificate.

See Also▲

See also https://

void QWebEnginePage::selectionChanged()▲

This signal is emitted whenever the selection changes, either interactively or programmatically. For example, by calling https://() with a selection action.

When using the mouse to select text by left-clicking and dragging, the signal will be emitted for each new character selected, and not upon releasing the left mouse button.

See Also▲

See also https://()

void QWebEnginePage::setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())▲

Sets the content of the web page to data. If the mimeType argument is empty, it is assumed that the content is text/plain,charset=US-ASCII.

External objects referenced in the content are located relative to baseUrl. For external objects with relative URLs to be loaded, baseUrl cannot be empty.

The data is loaded immediately; external objects are loaded asynchronously.

This method will not affect session or global history for the page.

The content will be percent encoded before being sent to the renderer via IPC. This may increase its size. The maximum size of the percent encoded content is 2 megabytes minus 6 bytes plus the length of the mime type string.

See Also▲

See also https://(), https://()

void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage)▲

Binds devToolsPage to be the developer tools of this page. Triggers devToolsPage to navigate to an internal URL with the developer tools.

This is the same as calling https://() on devToolsPage with this as argument.

See Also▲

See also https://(), https://()

void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)▲

Sets the permission for the web site identified by securityOrigin to use feature to policy.

This method is primarily for calling after a https://() signal has been emitted to trigger the feature permission response. It can also be called before a request has been emitted, but will only set a granted permission for passive checks, mainly for Notification APIs that can check if permission has already been granted before explicitly requesting it.

See Also▲

See also https://(), https://()

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

Sets the content of this page to html. baseUrl is optional and used to resolve relative URLs in the document, such as referenced images or stylesheets.

The html is loaded immediately; external objects are loaded asynchronously.

If a script in the html runs longer than the default script timeout (currently 10 seconds), for example due to being blocked by a modal JavaScript alert dialog, this method will return as soon as possible after the timeout and any subsequent html will be loaded asynchronously.

When using this method, the web engine 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. It is also possible for the encoding to be specified by the web server.

This is a convenience function equivalent to https://(html, "text/html", baseUrl).

This method will not affect session or global history for the page.

This function works only for HTML, for other mime types (such as XHTML and SVG) https://() should be used instead.

The content will be percent encoded before being sent to the renderer via IPC. This may increase its size. The maximum size of the percent encoded content is 2 megabytes minus 30 bytes.

See Also▲

See also https://(), https://(), https://()

void QWebEnginePage::setInspectedPage(QWebEnginePage *page)▲

Navigates this page to an internal URL that is the developer tools of page.

This is the same as calling https://() on page with this as argument.

See Also▲

See also https://(), https://()

void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)▲

Registers the request interceptor interceptor to intercept URL requests.

The page does not take ownership of the pointer. This interceptor is called after any interceptors on the profile, and unlike profile interceptors, only URL requests from this page are intercepted. If the original request was already blocked or redirected by the profile interceptor, it will not be intercepted by this.

To unset the request interceptor, set a nullptr.

See Also▲

See also https://, https://()

void QWebEnginePage::setWebChannel(QWebChannel *channel, quint32 worldId = 0)▲

Sets the web channel instance to be used by this page to channel and connects it to web engine's transport using Chromium IPC messages. The transport is exposed in the JavaScript world worldId as qt.webChannelTransport, which should be used when using the https://.

The page does not take ownership of the channel object.

Only one web channel can be installed per page, setting one even in another JavaScript world uninstalls any already installed web channel.

See Also▲

See also https://(), https://

QWebEngineSettings *QWebEnginePage::settings() const▲

Returns a pointer to the page's settings object.

void QWebEnginePage::titleChanged(const QString &title)▲

This signal is emitted whenever the title of the page changes. The title string specifies the new title.

See Also▲

See also https://()

void QWebEnginePage::toHtml(const std::function<void (const QString &)> &resultCallback) const▲

Asynchronous method to retrieve the page's content as HTML, enclosed in HTML and BODY tags. Upon successful completion, resultCallback is called with the page's content.

resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a https:// parameter.

We guarantee that the callback (resultCallback) is always called, but it might be done during page destruction. When https:// is deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding https:// or https:// instance inside it.

See Also▲

See also https://(), https://()

void QWebEnginePage::toPlainText(const std::function<void (const QString &)> &resultCallback) const▲

Asynchronous method to retrieve the page's content converted to plain text, completely stripped of all HTML formatting. Upon successful completion, resultCallback is called with the page's content.

resultCallback can be any of a function pointer, a functor or a lambda, and it is expected to take a https:// parameter.

We guarantee that the callback (resultCallback) is always called, but it might be done during page destruction. When https:// is deleted, the callback is triggered with an invalid value and it is not safe to use the corresponding https:// or https:// instance inside it.

See Also▲

See also https://()

[virtual] void QWebEnginePage::triggerAction(QWebEnginePage::WebAction action, bool checked = false)▲

This function can be called to trigger the specified action. It is also called by Qt WebEngine if the user triggers the action, for example through a context menu item.

If action is a checkable action, then checked specifies whether the action is toggled or not.

See Also▲

See also https://()

void QWebEnginePage::urlChanged(const QUrl &url)▲

This signal is emitted with the URL of the page when the page title is received. The new URL is specified by url.

Notifier signal for property https://.

See Also▲

See also https://()

[since 6.7] void QWebEnginePage::webAuthUxRequested(QWebEngineWebAuthUxRequest *request)▲

This signal is emitted when a WebAuth authenticator needs user interaction during the authentication process. These requests are handled by displaying a dialog to the user.

The request contains the information and API required to complete the WebAuth UX request.

This function was introduced in Qt 6.7.

See Also▲

See also https://

QWebChannel *QWebEnginePage::webChannel() const▲

Returns a pointer to the web channel instance used by this page or a null pointer if none was set. This channel automatically uses the internal web engine transport mechanism over Chromium IPC that is exposed in the JavaScript context of this page as qt.webChannelTransport.

See Also▲

See also https://()

void QWebEnginePage::windowCloseRequested()▲

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

See Also▲

See also https://

Obsolete Members for QWebEnginePage▲

The following members of class https:// are deprecated. We strongly advise against using them in new code.

Obsolete Member Function Documentation▲

 
void QWebEnginePage::quotaRequested(QWebEngineQuotaRequest quotaRequest)▲

This function is deprecated since 6.5. We strongly advise against using it in new code.

This signal is no longer emitted.

Requesting host quota is no longer supported by Chromium. The behavior of navigator.webkitPersistentStorage is identical to navigator.webkitTemporaryStorage.

For further details, see https://crbug.com/1233525

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.