QPlaceIcon Class
QPlaceIcon 类表示一个图标。更多内容...
| Header: | #include <QPlaceIcon> |
| qmake: | QT += location |
属性
- manager : QPlaceManager*
- parameters : QVariantMap
公共函数
| QPlaceIcon() | |
| QPlaceIcon(const QPlaceIcon &other) | |
| QPlaceIcon(QPlaceIcon &&other) | |
| ~QPlaceIcon() | |
| bool | isEmpty() const |
| QPlaceManager * | manager() const |
| QVariantMap | parameters() const |
| void | setManager(QPlaceManager *manager) |
| void | setParameters(const QVariantMap ¶meters) |
| QUrl | url(const QSize &size = QSize()) const |
| QPlaceIcon & | operator=(const QPlaceIcon &other) |
静态公共成员
| const QString | SingleUrl |
相关的非成员
| bool | operator!=(const QPlaceIcon &lhs, const QPlaceIcon &rhs) |
| bool | operator==(const QPlaceIcon &lhs, const QPlaceIcon &rhs) |
详细说明
图标的典型用法是使用url()函数来指定首选的图标尺寸。
QUrl iconSourceUrl = place.icon().url(QSize(32,32));
//A default icon may also be requested like so
iconSourceUrl = place.icon().url();图标通常取决于后端,如果管理器后端不支持给定的尺寸,则会返回最接近这些参数的图标 URL。
图标类还拥有一组键值对参数。需要使用的具体键取决于所使用的插件。这些参数会影响管理器返回的图标 URL,也可用于在保存图标时指定图标 URL 的位置。
如果一个图标仅有一张图片,则可将QPlaceIcon::SingleUrl 用作参数键,并以QUrl 作为关联值。如果设置了此键,则url()函数将始终返回指定的URL,而不会交由任何管理器处理。
属性文档
manager : QPlaceManager*
该属性保存了此图标的经理。
访问函数:
| QPlaceManager * | manager() const |
| void | setManager(QPlaceManager *manager) |
parameters : QVariantMap
该属性包含图标的参数集,这些参数与特定管理器或插件相关。
访问函数:
| QVariantMap | parameters() const |
| void | setParameters(const QVariantMap ¶meters) |
成员函数文档
QPlaceIcon::QPlaceIcon()
创建一个图标。
[noexcept] QPlaceIcon::QPlaceIcon(const QPlaceIcon &other)
创建other 的副本。
[constexpr noexcept default] QPlaceIcon::QPlaceIcon(QPlaceIcon &&other)
通过Move构造一个QPlaceIcon 的实例。
[noexcept] QPlaceIcon::~QPlaceIcon()
删除该图标。
bool QPlaceIcon::isEmpty() const
返回一个布尔值,表示图标的所有字段是否均为空。
QPlaceManager *QPlaceIcon::manager() const
返回与该图标关联的管理器。
注意: 这是 manager 属性的获取 函数。
另请参阅 setManager()。
QVariantMap QPlaceIcon::parameters() const
返回一组针对该图标的、特定于管理器/插件的参数。当调用url() 时,管理器会使用这些参数返回相应的 URL,并在保存图标时指定保存位置。
有关支持哪些参数以及如何使用它们,请参阅插件文档。
注意: 这是用于属性参数的获取 函数。
另请参阅 setParameters()。
void QPlaceIcon::setManager(QPlaceManager *manager)
设置与该图标关联的manager 。该图标不会获取该指针的所有权。
注意: 这是属性manager 的设置 函数。
另请参阅 manager()。
void QPlaceIcon::setParameters(const QVariantMap ¶meters)
将图标的参数设置为parameters 。
注意: 这是属性parameters 的设置 函数。
另请参阅 parameters()。
[invokable] QUrl QPlaceIcon::url(const QSize &size = QSize()) const
根据给定的size 返回一个图标URL。
如果该图标未被分配任何管理器,且参数中不包含QPlaceIcon::SingleUrl 键,则返回一个默认构造的QUrl 。
注意: 可以通过元对象系统和 QML 调用此 函数。参见Q_INVOKABLE 。
[noexcept] QPlaceIcon &QPlaceIcon::operator=(const QPlaceIcon &other)
将other 赋值给此图标,并返回对此图标的引用。
成员变量文档
const QString QPlaceIcon::SingleUrl
仅包含单个图片 URL 的图标的参数键。
与该键配合使用的参数值为QUrl 。设置了此参数的图标在调用url() 时,无论请求的尺寸如何,都会始终返回指定的 URL。
相关非成员
[noexcept] bool operator!=(const QPlaceIcon &lhs, const QPlaceIcon &rhs)
如果 `lhs ` 不等于 `rhs`,则返回 `true`;否则返回 `false`。
[noexcept] bool operator==(const QPlaceIcon &lhs, const QPlaceIcon &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.