QPlaceAttribute Class

QPlaceAttribute 类表示一个地方的通用属性信息。更多

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

属性

公共函数

QPlaceAttribute()
QPlaceAttribute(const 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 的副本。

[noexcept] QPlaceAttribute::~QPlaceAttribute()

销毁属性。

bool QPlaceAttribute::isEmpty() const

返回一个布尔值,表示地点属性的所有字段是否为空。

[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。

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