本页内容

QCoapRequest Class

QCoapRequest 类用于存储一个 CoAP 请求。该请求可通过 `QCoapClient` 发送。更多内容...

头文件: #include <QCoapRequest>
CMake: find_package(Qt6 REQUIRED COMPONENTS Coap)
target_link_libraries(mytarget PRIVATE Qt6::Coap)
qmake: QT += coap
继承自: QCoapMessage

注意:该类中的所有函数均为可重入函数。

公共函数

QCoapRequest(const char *url, QCoapMessage::Type type = Type::NonConfirmable)
QCoapRequest(const QUrl &url = QUrl(), QCoapMessage::Type type = Type::NonConfirmable, const QUrl &proxyUrl = QUrl())
QCoapRequest(const QCoapRequest &other)
~QCoapRequest()
void enableObserve()
bool isObserve() const
QtCoap::Method method() const
QUrl proxyUrl() const
void setProxyUrl(const QUrl &proxyUrl)
void setUrl(const QUrl &url)
QUrl url() const
QCoapRequest &operator=(const QCoapRequest &other)

详细描述

QCoapRequest 包含用于构建 CoAP 帧所需的数据,这些帧可发送至其持有的 URL。

另请参阅 QCoapClient 、QCoapReply 和QCoapResourceDiscoveryReply 。

成员函数文档

[explicit] QCoapRequest::QCoapRequest(const char *url, QCoapMessage::Type type = Type::NonConfirmable)

根据字符串字面量构建一个 QCoapRequest 对象

[explicit] QCoapRequest::QCoapRequest(const QUrl &url = QUrl(), QCoapMessage::Type type = Type::NonConfirmable, const QUrl &proxyUrl = QUrl())

根据目标url 、代理 URLproxyUrl 以及消息的type 创建一个 QCoapRequest 对象。

QCoapRequest::QCoapRequest(const QCoapRequest &other)

创建一个other 的QCoapRequest实例的副本。

[noexcept] QCoapRequest::~QCoapRequest()

销毁QCoapRequest 。

void QCoapRequest::enableObserve()

将 observe 设置为true 以发起观察请求。

另请参阅 isObserve()。

bool QCoapRequest::isObserve() const

如果请求是“观察”请求,则返回true 。

另请参阅 enableObserve()。

QtCoap::Method QCoapRequest::method() const

返回请求的方法。

QUrl QCoapRequest::proxyUrl() const

返回请求的代理 URI。如果该 URI 无效,则应直接发送请求。

另请参阅 setProxyUrl()。

void QCoapRequest::setProxyUrl(const QUrl &proxyUrl)

将请求的代理 URI 设置为指定的proxyUrl 。

另请参阅 proxyUrl()。

void QCoapRequest::setUrl(const QUrl &url)

将请求的目标 URI 设置为给定的url 。

如果未指定,URL 的方案将默认为 'coap',端口将默认为 5683。

另请参阅 url()。

QUrl QCoapRequest::url() const

返回请求的目标 URI。

另请参阅 setUrl()。

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

创建other 的副本。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.