QPlaceIcon Class

QPlaceIcon 类表示一个图标。更多

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

公共函数

QPlaceIcon()
QPlaceIcon(const QPlaceIcon &other)
~QPlaceIcon()
bool isEmpty() const
QPlaceManager *manager() const
QVariantMap parameters() const
void setManager(QPlaceManager *manager)
void setParameters(const QVariantMap &parameters)
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,而不会转给任何管理器。

成员函数文档

QPlaceIcon::QPlaceIcon()

构建一个图标。

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

构造other 的副本。

[noexcept] QPlaceIcon::~QPlaceIcon()

销毁图标。

bool QPlaceIcon::isEmpty() const

返回一个布尔值,表示图标的所有字段是否为空。

QPlaceManager *QPlaceIcon::manager() const

返回此图标关联的管理器。

注: 属性管理器的获取函数。

另请参阅 setManager()。

QVariantMap QPlaceIcon::parameters() const

返回图标的一组特定于管理器/插件的参数。管理器会使用这些参数在调用url() 时返回相应的 URL,并在保存图标时指定保存位置。

关于支持哪些参数以及如何使用这些参数,请查阅插件文档

注: 属性参数的获取函数。

另请参阅 setParameters()。

void QPlaceIcon::setManager(QPlaceManager *manager)

设置与该图标相关联的manager 。图标不拥有指针的所有权。

注: manager 属性的设置函数。

另请参阅 manager()。

void QPlaceIcon::setParameters(const QVariantMap &parameters)

将图标参数设置为parameters

注: 属性parameters 的设置函数。

另请参阅 parameters() 。

[invokable] QUrl QPlaceIcon::url(const QSize &size = QSize()) const

根据给定的size 返回图标 URL。

如果没有为图标指定管理器,且参数不包含QPlaceIcon::SingleUrl key,则返回默认构造的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。

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