QWebEngineHttpRequest Class

The QWebEngineHttpRequest class holds a request to be sent with WebEngine . 更多...

头: #include <QWebEngineHttpRequest>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore

公共类型

enum Method { Get, Post }

公共函数

QWebEngineHttpRequest (const QUrl & url = QUrl(), const QWebEngineHttpRequest::Method & method = QWebEngineHttpRequest::Get)
QWebEngineHttpRequest (const QWebEngineHttpRequest & other )
~QWebEngineHttpRequest ()
bool hasHeader (const QByteArray & headerName ) const
QByteArray header (const QByteArray & headerName ) const
QList<QByteArray> headers () const
QWebEngineHttpRequest::Method 方法 () const
QByteArray postData () const
void setHeader (const QByteArray & headerName , const QByteArray & headerValue )
void setMethod (QWebEngineHttpRequest::Method method )
void setPostData (const QByteArray & postData )
void setUrl (const QUrl & url )
void swap (QWebEngineHttpRequest & other )
void unsetHeader (const QByteArray & key )
QUrl url () const
bool operator!= (const QWebEngineHttpRequest & other ) const
QWebEngineHttpRequest & operator= (const QWebEngineHttpRequest & other )
bool operator== (const QWebEngineHttpRequest & other ) const

静态公共成员

QWebEngineHttpRequest postRequest (const QUrl & url , const QMap<QString, QString> & postData )

详细描述

QWebEngineHttpRequest represents an HTTP request in the WebEngine networking stack. It holds the information necessary to send a request over the network. It contains a URL and some ancillary information that can be used to modify the request. Both QWebEnginePage::load () 和 QWebEngineView::load () accept a QWebEngineHttpRequest as a parameter.

成员类型文档编制

enum QWebEngineHttpRequest:: 方法

This enum type describes the method used to send the HTTP request:

常量 描述
QWebEngineHttpRequest::Get 0 The GET method.
QWebEngineHttpRequest::Post 1 The POST method.

成员函数文档编制

[explicit] QWebEngineHttpRequest:: QWebEngineHttpRequest (const QUrl & url = QUrl(), const QWebEngineHttpRequest::Method & method = QWebEngineHttpRequest::Get)

Constructs a QWebEngineHttpRequest object with url as the URL to be requested and method as the method to be used.

另请参阅 url () 和 setUrl ().

QWebEngineHttpRequest:: QWebEngineHttpRequest (const QWebEngineHttpRequest & other )

创建副本为 other .

[noexcept] QWebEngineHttpRequest:: ~QWebEngineHttpRequest ()

Disposes of the QWebEngineHttpRequest 对象。

bool QWebEngineHttpRequest:: hasHeader (const QByteArray & headerName ) const

返回 true if the header headerName is present in this WebEngine request.

另请参阅 setHeader (), header (), unsetHeader (),和 headers ().

Returns the header specified by headerName 。若不存在这种 Header (头),空 QByteArray 被返回,可能难以区分存在但没有内容的 Header 头 (使用 hasHeader () 以确定 Header 头是否存在)。

Headers can be set with setHeader ().

另请参阅 setHeader (), hasHeader (), unsetHeader (),和 headers ().

QList < QByteArray > QWebEngineHttpRequest:: headers () const

Returns a list of all headers that are set in this WebEngine request. The list is in the order that the headers were set.

另请参阅 setHeader (), header (), hasHeader (),和 unsetHeader ().

QWebEngineHttpRequest::Method QWebEngineHttpRequest:: 方法 () const

Returns the method this WebEngine request is using.

另请参阅 setMethod ().

QByteArray QWebEngineHttpRequest:: postData () const

Returns the (raw) POST data this WebEngine request contains.

另请参阅 setPostData ().

[static] QWebEngineHttpRequest QWebEngineHttpRequest:: postRequest (const QUrl & url , const QMap < QString , QString > & postData )

构造 QWebEngineHttpRequest to url that uses the POST method.

注意: postData may contain arbitrary strings. They are translated to appropriate raw data.

另请参阅 postData and setPostData ().

void QWebEngineHttpRequest:: setHeader (const QByteArray & headerName , const QByteArray & headerValue )

设置 Header (头) headerName 到值 headerValue .

注意: Setting the same header twice overrides the previous setting. To accomplish the behavior of multiple HTTP headers of the same name, you should concatenate the two values, separating them with a comma (",") and set one single header.

另请参阅 header (), hasHeader (), unsetHeader (),和 headers ().

void QWebEngineHttpRequest:: setMethod ( QWebEngineHttpRequest::Method method )

Sets the method this WebEngine request is using to be method .

另请参阅 方法 ().

void QWebEngineHttpRequest:: setPostData (const QByteArray & postData )

Sets the (raw) POST data this WebEngine request contains to be postData .

另请参阅 postData ().

void QWebEngineHttpRequest:: setUrl (const QUrl & url )

Sets the URL this WebEngine request is referring to be url .

另请参阅 url ().

[noexcept] void QWebEngineHttpRequest:: swap ( QWebEngineHttpRequest & other )

交换此 WebEngine request with other 。此函数非常快且从不失败。

void QWebEngineHttpRequest:: unsetHeader (const QByteArray & key )

Removes the header specified by key , if present.

另请参阅 setHeader (), header (), hasHeader (),和 headers ().

QUrl QWebEngineHttpRequest:: url () const

Returns the URL this WebEngine request is referring to.

另请参阅 setUrl ().

bool QWebEngineHttpRequest:: operator!= (const QWebEngineHttpRequest & other ) const

返回 false if this object is not the same as other .

另请参阅 operator== ().

QWebEngineHttpRequest &QWebEngineHttpRequest:: operator= (const QWebEngineHttpRequest & other )

创建副本为 other .

bool QWebEngineHttpRequest:: operator== (const QWebEngineHttpRequest & other ) const

返回 true if this object is the same as other (that is, if they have the same method, URL, and headers).

另请参阅 operator!= ().