本页内容

QNdefNfcSmartPosterRecord Class

QNdefNfcSmartPosterRecord 类提供了一个 NFC RTD-SmartPoster。更多内容...

头文件: #include <QNdefNfcSmartPosterRecord>
CMake: find_package(Qt6 REQUIRED COMPONENTS Nfc)
target_link_libraries(mytarget PRIVATE Qt6::Nfc)
qmake: QT += nfc
自: Qt 5.2
继承自: QNdefRecord

公共类型

enum Action { UnspecifiedAction, DoAction, SaveAction, EditAction }

公共函数

QNdefNfcSmartPosterRecord()
QNdefNfcSmartPosterRecord(const QNdefRecord &other)
QNdefNfcSmartPosterRecord(const QNdefNfcSmartPosterRecord &other)
~QNdefNfcSmartPosterRecord()
QNdefNfcSmartPosterRecord::Action action() const
void addIcon(const QNdefNfcIconRecord &icon)
void addIcon(const QByteArray &type, const QByteArray &data)
bool addTitle(const QNdefNfcTextRecord &text)
bool addTitle(const QString &text, const QString &locale, QNdefNfcTextRecord::Encoding encoding)
bool hasAction() const
bool hasIcon(const QByteArray &mimetype = QByteArray()) const
bool hasSize() const
bool hasTitle(const QString &locale = QString()) const
bool hasTypeInfo() const
QByteArray icon(const QByteArray &mimetype = QByteArray()) const
qsizetype iconCount() const
QNdefNfcIconRecord iconRecord(qsizetype index) const
QList<QNdefNfcIconRecord> iconRecords() const
bool removeIcon(const QByteArray &type)
bool removeIcon(const QNdefNfcIconRecord &icon)
bool removeTitle(const QNdefNfcTextRecord &text)
bool removeTitle(const QString &locale)
void setAction(QNdefNfcSmartPosterRecord::Action act)
void setIcons(const QList<QNdefNfcIconRecord> &icons)
void setSize(quint32 size)
void setTitles(const QList<QNdefNfcTextRecord> &titles)
void setTypeInfo(const QString &type)
void setUri(const QNdefNfcUriRecord &url)
void setUri(const QUrl &url)
quint32 size() const
QString title(const QString &locale = QString()) const
qsizetype titleCount() const
QNdefNfcTextRecord titleRecord(qsizetype index) const
QList<QNdefNfcTextRecord> titleRecords() const
QString typeInfo() const
QUrl uri() const
QNdefNfcUriRecord uriRecord() const
QNdefNfcSmartPosterRecord &operator=(const QNdefNfcSmartPosterRecord &other)

详细描述

RTD-SmartPoster 封装了一个 Smart Poster。

成员类型文档

enum QNdefNfcSmartPosterRecord::Action

此枚举描述了设备应对该内容应采取的操作。

常量值描述
QNdefNfcSmartPosterRecord::UnspecifiedAction-1未定义该操作。
QNdefNfcSmartPosterRecord::DoAction0执行该操作(发送短信、启动浏览器、拨打电话)。
QNdefNfcSmartPosterRecord::SaveAction1保存以备后用(将短信保存在“收件箱”中、将 URI 添加到书签、将电话号码保存到通讯录中)。
QNdefNfcSmartPosterRecord::EditAction2打开以进行编辑(在短信编辑器中打开短信、在 URI 编辑器中打开 URI、打开电话号码以进行编辑)。

成员函数文档

QNdefNfcSmartPosterRecord::QNdefNfcSmartPosterRecord()

创建一个新的空智能海报。

QNdefNfcSmartPosterRecord::QNdefNfcSmartPosterRecord(const QNdefRecord &other)

创建一个新的智能海报,该海报是other 的副本。

QNdefNfcSmartPosterRecord::QNdefNfcSmartPosterRecord(const QNdefNfcSmartPosterRecord &other)

创建一个新的智能海报,该海报是other 的副本。

[noexcept] QNdefNfcSmartPosterRecord::~QNdefNfcSmartPosterRecord()

销毁智能海报。

QNdefNfcSmartPosterRecord::Action QNdefNfcSmartPosterRecord::action() const

如果存在,则返回操作记录中的操作;否则返回UnspecifiedAction 。

另请参阅 setAction()。

void QNdefNfcSmartPosterRecord::addIcon(const QNdefNfcIconRecord &icon)

向智能海报中添加一个图标记录icon 。如果智能海报中已经包含同类型的图标记录,则替换现有的图标记录。

void QNdefNfcSmartPosterRecord::addIcon(const QByteArray &type, const QByteArray &data)

向智能海报中添加一个类型为type 、数据为data 的图标记录。如果智能海报中已存在类型相同的图标记录,则替换该现有图标记录。

bool QNdefNfcSmartPosterRecord::addTitle(const QNdefNfcTextRecord &text)

尝试向智能海报添加标题记录text 。如果智能海报中尚不存在与标题记录text 具有相同区域设置的标题记录,则添加该标题记录,且函数返回true 。否则,返回false 。

bool QNdefNfcSmartPosterRecord::addTitle(const QString &text, const QString &locale, QNdefNfcTextRecord::Encoding encoding)

尝试添加一条新标题记录,其标题为text ,语言环境为locale ,编码为encoding 。如果智能海报中尚未包含语言环境为locale 的标题记录,则添加该标题记录,并返回true 。否则返回false 。

bool QNdefNfcSmartPosterRecord::hasAction() const

如果智能海报包含一个操作记录,则返回true ;否则返回false 。

bool QNdefNfcSmartPosterRecord::hasIcon(const QByteArray &mimetype = QByteArray()) const

如果智能海报中包含类型为mimetype 的图标记录,则返回true 。如果mimetype 为空,且智能海报中至少包含一条图标记录,则返回true 。在所有其他情况下,返回false 。

bool QNdefNfcSmartPosterRecord::hasSize() const

如果智能海报包含尺寸记录,则返回true ;否则返回false 。

bool QNdefNfcSmartPosterRecord::hasTitle(const QString &locale = QString()) const

如果智能海报中包含使用区域设置locale 的标题记录,则返回true 。如果locale 为空,且智能海报中至少包含一条标题记录,则返回true 。在所有其他情况下,返回false 。

bool QNdefNfcSmartPosterRecord::hasTypeInfo() const

如果智能海报包含类型记录,则返回true ;否则返回false 。

QByteArray QNdefNfcSmartPosterRecord::icon(const QByteArray &mimetype = QByteArray()) const

如果智能海报中包含 MIME 类型为mimetype 的图标记录,则返回该图标记录的数据。如果省略或未填写mimetype ,则返回第一个图标的记录数据。在所有其他情况下,返回一个空数组。

警告: 建议应用程序开发人员 在处理返回的数据之前对其进行验证。请参阅《Qt NFC 安全注意事项》以获取相关指导。

qsizetype QNdefNfcSmartPosterRecord::iconCount() const

返回智能海报中包含的图标记录数量。

QNdefNfcIconRecord QNdefNfcSmartPosterRecord::iconRecord(qsizetype index) const

返回智能海报中索引index 对应的图标记录,其中index 的取值范围为0到iconCount() - 1。超出此范围的值将返回空记录。

QList<QNdefNfcIconRecord> QNdefNfcSmartPosterRecord::iconRecords() const

返回智能海报中所有图标记录的副本。

bool QNdefNfcSmartPosterRecord::removeIcon(const QByteArray &type)

尝试从智能海报中删除类型为type 的图标记录。若智能海报中包含匹配的记录,则删除该记录并返回true ;否则返回false 。

bool QNdefNfcSmartPosterRecord::removeIcon(const QNdefNfcIconRecord &icon)

尝试从智能海报中删除图标记录icon 。如果智能海报中包含匹配的记录,则删除该记录并返回true ;否则返回false 。

bool QNdefNfcSmartPosterRecord::removeTitle(const QNdefNfcTextRecord &text)

尝试从智能海报中删除标题记录text 。如果智能海报中包含匹配的记录,则删除该记录并返回true ;否则返回false 。

bool QNdefNfcSmartPosterRecord::removeTitle(const QString &locale)

尝试从智能海报中删除一个区域设置为locale 的标题记录。如果智能海报中包含匹配的记录,则删除该记录并返回true ;否则返回false 。

void QNdefNfcSmartPosterRecord::setAction(QNdefNfcSmartPosterRecord::Action act)

将操作记录设置为act

另请参阅 action()。

void QNdefNfcSmartPosterRecord::setIcons(const QList<QNdefNfcIconRecord> &icons)

将图标记录列表icons 添加到智能海报中。任何现有记录都将被覆盖。

另请参阅 hasIcon() 和icon()。

void QNdefNfcSmartPosterRecord::setSize(quint32 size)

设置记录size 。该值包含 URI 所指对象的大小(以字节为单位)。

另请参阅 size() 和hasSize()。

void QNdefNfcSmartPosterRecord::setTitles(const QList<QNdefNfcTextRecord> &titles)

将标题记录列表titles 添加到智能海报中。任何现有记录都将被覆盖。

void QNdefNfcSmartPosterRecord::setTypeInfo(const QString &type)

将类型记录设置为type 。type 描述了uri()所引用的对象的类型。

另请参阅 typeInfo()。

void QNdefNfcSmartPosterRecord::setUri(const QNdefNfcUriRecord &url)

将 URI 记录设置为url

另请参阅 uri()。

void QNdefNfcSmartPosterRecord::setUri(const QUrl &url)

构建一个 URI 记录,并将其内容设置在智能海报中,使其为url

quint32 QNdefNfcSmartPosterRecord::size() const

如果存在大小记录,则返回该记录中的大小;否则返回 0。

该值是可选的,包含 URI 所指对象的大小(以字节为单位)。设备可利用该值来判断其是否能够容纳该对象。

另请参阅 setSize()。

QString QNdefNfcSmartPosterRecord::title(const QString &locale = QString()) const

返回与区域设置locale 关联的标题记录文本(如果存在)。如果locale 为空,则返回第一个可用记录的标题文本。在所有其他情况下,返回空字符串。

qsizetype QNdefNfcSmartPosterRecord::titleCount() const

返回智能海报中包含的标题记录数量。

QNdefNfcTextRecord QNdefNfcSmartPosterRecord::titleRecord(qsizetype index) const

返回智能海报中索引为index 的标题记录,其中index 的取值范围为0到titleCount() - 1。超出此范围的值将返回空记录。

QList<QNdefNfcTextRecord> QNdefNfcSmartPosterRecord::titleRecords() const

返回智能海报中所有标题记录的副本。

QString QNdefNfcSmartPosterRecord::typeInfo() const

返回描述可通过uri()访问的对象类型的MIME类型。

如果类型未知,则返回的QString 为空。

另请参阅 setTypeInfo() 和hasTypeInfo()。

QUrl QNdefNfcSmartPosterRecord::uri() const

如果已设置,则返回智能海报的 URI 记录中的 URI;否则返回空 URI。

警告: 建议应用程序 开发人员在根据返回的 URI 采取行动之前对其进行验证。请参阅Qt NFC 中的“安全注意事项”以获取指导。

另请参阅 setUri()。

QNdefNfcUriRecord QNdefNfcSmartPosterRecord::uriRecord() const

如果已设置,则返回智能海报的 URI 记录;否则返回一个空 URI。

QNdefNfcSmartPosterRecord &QNdefNfcSmartPosterRecord::operator=(const QNdefNfcSmartPosterRecord &other)

将other 智能海报记录分配给此记录,并返回对此记录的引用。

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