The QWebEngineUrlRequestInfo class provides information about URL requests. 更多...
头: | #include <QWebEngineUrlRequestInfo> |
CMake: |
find_package(Qt6 COMPONENTS WebEngineCore REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore) |
qmake: | QT += webenginecore |
Since: | Qt 5.6 |
enum | NavigationType { NavigationTypeLink, NavigationTypeTyped, NavigationTypeFormSubmitted, NavigationTypeBackForward, NavigationTypeReload, …, NavigationTypeOther } |
enum | ResourceType { ResourceTypeMainFrame, ResourceTypeSubFrame, ResourceTypeStylesheet, ResourceTypeScript, ResourceTypeImage, …, ResourceTypeUnknown } |
void | block (bool shouldBlock ) |
QUrl | firstPartyUrl () const |
QUrl | initiator () const |
QWebEngineUrlRequestInfo::NavigationType | navigationType () const |
void | redirect (const QUrl & url ) |
QByteArray | requestMethod () const |
QUrl | requestUrl () const |
QWebEngineUrlRequestInfo::ResourceType | resourceType () const |
void | setHttpHeader (const QByteArray & name , const QByteArray & value ) |
The QWebEngineUrlRequestInfo is useful for setting extra header fields for requests or for redirecting certain requests without payload data to another URL. This class cannot be instantiated or copied by the user, instead it will be created by Qt WebEngine and sent through the virtual function QWebEngineUrlRequestInterceptor::interceptRequest () if an interceptor has been set.
This enum type describes the navigation type of the request:
常量 | 值 | 描述 |
---|---|---|
QWebEngineUrlRequestInfo::NavigationTypeLink
|
0
|
Navigation initiated by clicking a link. |
QWebEngineUrlRequestInfo::NavigationTypeTyped
|
1
|
Navigation explicitly initiated by typing a URL. |
QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted
|
2
|
Navigation submits a form. |
QWebEngineUrlRequestInfo::NavigationTypeBackForward
|
3
|
Navigation initiated by a history action. |
QWebEngineUrlRequestInfo::NavigationTypeReload
|
4
|
Navigation initiated by refreshing the page. |
QWebEngineUrlRequestInfo::NavigationTypeRedirect
|
6
|
Navigation triggered automatically by page content or remote server. (Added in Qt 5.14) |
QWebEngineUrlRequestInfo::NavigationTypeOther
|
5
|
None of the above. |
This enum type holds the type of the requested resource:
常量 | 值 | 描述 |
---|---|---|
QWebEngineUrlRequestInfo::ResourceTypeMainFrame
|
0
|
Top level page. |
QWebEngineUrlRequestInfo::ResourceTypeSubFrame
|
1
|
Frame or iframe. |
QWebEngineUrlRequestInfo::ResourceTypeStylesheet
|
2
|
A CSS stylesheet. |
QWebEngineUrlRequestInfo::ResourceTypeScript
|
3
|
An external script. |
QWebEngineUrlRequestInfo::ResourceTypeImage
|
4
|
An image (JPG, GIF, PNG, and so on). |
QWebEngineUrlRequestInfo::ResourceTypeFontResource
|
5
|
A font. |
QWebEngineUrlRequestInfo::ResourceTypeSubResource
|
6
|
An "other" subresource. |
QWebEngineUrlRequestInfo::ResourceTypeObject
|
7
|
An object (or embed) tag for a plugin or a resource that a plugin requested. |
QWebEngineUrlRequestInfo::ResourceTypeMedia
|
8
|
A media resource. |
QWebEngineUrlRequestInfo::ResourceTypeWorker
|
9
|
The main resource of a dedicated worker. |
QWebEngineUrlRequestInfo::ResourceTypeSharedWorker
|
10
|
The main resource of a shared worker. |
QWebEngineUrlRequestInfo::ResourceTypePrefetch
|
11
|
An explicitly requested prefetch. |
QWebEngineUrlRequestInfo::ResourceTypeFavicon
|
12
|
A favicon. |
QWebEngineUrlRequestInfo::ResourceTypeXhr
|
13
|
An XMLHttpRequest. |
QWebEngineUrlRequestInfo::ResourceTypePing
|
14
|
A ping request for <a ping>. |
QWebEngineUrlRequestInfo::ResourceTypeServiceWorker
|
15
|
The main resource of a service worker. |
QWebEngineUrlRequestInfo::ResourceTypeCspReport
|
16
|
A report of Content Security Policy (CSP) violations. CSP reports are in JSON format and they are delivered by HTTP POST requests to specified servers. (Added in Qt 5.7) |
QWebEngineUrlRequestInfo::ResourceTypePluginResource
|
17
|
A resource requested by a plugin. (Added in Qt 5.7) |
QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadMainFrame
|
19
|
A main-frame service worker navigation preload request. (Added in Qt 5.14) |
QWebEngineUrlRequestInfo::ResourceTypeNavigationPreloadSubFrame
|
20
|
A sub-frame service worker navigation preload request. (Added in Qt 5.14) |
QWebEngineUrlRequestInfo::ResourceTypeUnknown
|
255
|
Unknown request type. |
注意:
For forward compatibility all values not matched should be treated as unknown, not just
ResourceTypeUnknown
.
Blocks this request if shouldBlock is true, so that it will not proceed.
This function can be used to prevent navigating away from a given domain, for example.
Returns the first party URL of the request. The first party URL is the URL of the page that issued the request.
[since 5.14]
QUrl
QWebEngineUrlRequestInfo::
initiator
() const
Returns the origin URL of the document that initiated the navigation of a frame to another frame.
该函数在 Qt 5.14 引入。
Returns the navigation type of the request.
另请参阅 NavigationType .
Redirects this request to url . It is only possible to redirect requests that do not have payload data, such as GET requests.
Returns the HTTP method of the request (for example, GET or POST).
Returns the requested URL.
Returns the resource type of the request.
另请参阅 ResourceType .
Sets the request header name to value for this request.