本页内容

QPlaceAttribute Class

QPlaceAttribute 类表示有关某个地点的通用属性信息。更多内容...

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

属性

公共函数

QPlaceAttribute()
QPlaceAttribute(const QPlaceAttribute &other)
QPlaceAttribute(QPlaceAttribute &&other)
~QPlaceAttribute()
bool isEmpty() const
QString label() const
void setLabel(const QString &label)
void setText(const QString &text)
QString text() const
QPlaceAttribute &operator=(const QPlaceAttribute &other)

静态公共成员

const QString OpeningHours
const QString Payment
const QString Provider
bool operator!=(const QPlaceAttribute &lhs, const QPlaceAttribute &rhs)
bool operator==(const QPlaceAttribute &lhs, const QPlaceAttribute &rhs)

详细说明

QPlaceAttribute 实例用于存储有关某个位置的额外信息,这些信息无法通过QPlace 类直接获取。QPlaceAttribute 封装了一个描述该属性的本地化标签,以及表示该属性值的富文本字符串。通常,这两者都旨在原样显示给最终用户。

某些插件可能完全不支持属性,有些可能仅支持特定的一组属性,还有些可能支持随时间动态变化的属性集,甚至允许客户端应用程序任意定义属性。属性也可能因地点而异,例如一个地点可能有营业时间,而另一个则没有。 详情请参阅插件参考文档。

属性类型

QPlaceAttribute 类定义了一些常量字符串,用于描述标准属性类型。

还有一类属性类型采用 x_id_<provider> 的格式,例如 x_id_here。这一类属性是从指定提供商的角度来看,该地点的一组替代标识符。

上述类型用于通过以下方式访问和修改QPlace 中的属性:

该属性类型为字符串类型,以便提供商能够根据需要引入新属性。自定义属性类型应始终以限定符作为前缀,以避免冲突。

用户可读和不可读属性

某些属性可能不打算供最终用户阅读,此类属性的标签字段为空以表明这一点。

属性文档

label : QString

该属性包含一个描述该属性的本地化标签。

访问函数:

QString label() const
void setLabel(const QString &label)

text : QString

该属性存储一段富文本,用于表示属性值。

访问函数:

QString text() const
void setText(const QString &text)

成员函数文档

QPlaceAttribute::QPlaceAttribute()

创建一个属性。

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

创建other 的副本。

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

通过Move构造一个QPlaceAttribute 实例。

[noexcept] QPlaceAttribute::~QPlaceAttribute()

删除该属性。

bool QPlaceAttribute::isEmpty() const

返回一个布尔值,用于指示“place”属性的所有字段是否均为空。

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

将other 赋值给该属性,并返回该属性的引用。

成员变量文档

const QString QPlaceAttribute::OpeningHours

指定营业时间。

const QString QPlaceAttribute::Payment

用于指定定义支付方式的属性的常量。

const QString QPlaceAttribute::Provider

用于指定一个属性的常量,该属性定义了该地点来自哪个提供商。

相关非成员

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

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

[noexcept] bool operator==(const QPlaceAttribute &lhs, const QPlaceAttribute &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.