本页内容

QPlaceContentRequest Class

QPlaceContentRequest 类表示内容请求的参数。更多内容...

Header: #include <QPlaceContentRequest>
qmake: QT += location

公共函数

QPlaceContentRequest()
QPlaceContentRequest(const QPlaceContentRequest &other)
QPlaceContentRequest(QPlaceContentRequest &&other)
~QPlaceContentRequest()
void clear()
QVariant contentContext() const
QPlaceContent::Type contentType() const
int limit() const
QString placeId() const
void setContentContext(const QVariant &context)
void setContentType(QPlaceContent::Type type)
void setLimit(int limit)
void setPlaceId(const QString &identifier)
QPlaceContentRequest &operator=(const QPlaceContentRequest &other)
bool operator!=(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs)
bool operator==(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs)

详细说明

QPlaceContentRequest 类与QPlaceManager 配合使用,用于以分页方式检索图像和评论等丰富内容。以下代码将从第 10 个索引处请求一组 5 张图像:

QPlaceContentRequest request;
request.setContentType(QPlaceContent::ImageType);
request.setPlaceId(place.placeId());
request.setLimit(5);

QPlaceContentReply *contentReply = manager->getPlaceContent(request);
//..connect signals..//
    ...
    ...
void contentHandler() {
    if (contentReply->error() == QPlaceReply::NoError)  {
        place.insertContent(contentReply->request().contentType(),
                            contentReply->content());
    }
}

另请参阅 QPlaceContentReply 。

成员函数文档

QPlaceContentRequest::QPlaceContentRequest()

创建一个新的请求对象。

[noexcept] QPlaceContentRequest::QPlaceContentRequest(const QPlaceContentRequest &other)

创建other 的副本。

[constexpr noexcept default] QPlaceContentRequest::QPlaceContentRequest(QPlaceContentRequest &&other)

通过Move构造一个QPlaceContentRequest 的实例。

[noexcept] QPlaceContentRequest::~QPlaceContentRequest()

销毁请求对象

void QPlaceContentRequest::clear()

清除内容请求。

QVariant QPlaceContentRequest::contentContext() const

返回与该地点内容请求相关联的、后端特有的附加内容上下文。

另请参阅 setContentContext()。

QPlaceContent::Type QPlaceContentRequest::contentType() const

返回要请求的内容类型,例如评论或图片

另请参阅 setContentType()。

int QPlaceContentRequest::limit() const

返回要检索的内容项的最大数量。

如果 limit 参数为负数,则表示该参数未定义。具体返回多少条内容项,由后端提供商自行决定。

默认限制值为 -1。

另请参阅 setLimit()。

QString QPlaceContentRequest::placeId() const

返回要从中获取内容的位置的标识符。

另请参阅 setPlaceId()。

void QPlaceContentRequest::setContentContext(const QVariant &context)

将内容上下文设置为context 。

注意:此 方法旨在供地理服务插件在返回地点内容结果时使用。

后端会使用内容上下文来存储与内容请求相关的附加信息。其他相关字段也应予以填写。例如,如果内容请求是针对图像内容的,则应通过setContentType() 设置内容类型。内容上下文允许保存一些无法通过Qt Location API 直接访问的附加信息。

内容上下文可以是任何可存储在QVariant 中的类型。内容上下文的值不供应用程序直接使用。

另请参阅 contentContext()。

void QPlaceContentRequest::setContentType(QPlaceContent::Type type)

设置要请求的内容的type 属性。

另请参阅 contentType()。

void QPlaceContentRequest::setLimit(int limit)

将要检索的内容项最大数量设置为limit 。

另请参阅 limit()。

void QPlaceContentRequest::setPlaceId(const QString &identifier)

将要获取内容的位置标识符设置为identifier 。

另请参阅 placeId()。

[noexcept] QPlaceContentRequest &QPlaceContentRequest::operator=(const QPlaceContentRequest &other)

将other 分配给此内容请求,并返回对此内容请求的引用。

相关非成员

[noexcept] bool operator!=(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs)

如果 `lhs ` 不等于 `rhs`,则返回 true;否则返回 false。

[noexcept] bool operator==(const QPlaceContentRequest &lhs, const QPlaceContentRequest &rhs)

如果lhs 等于rhs ,则返回true;否则返回false。

© 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.