このページでは

QMqttMessage Class

QMqttMessage クラスは、サブスクリプションに基づいてメッセージブローカーから受信したメッセージに関する情報を提供します。詳細...

ヘッダー: #include <QMqttMessage>
CMake: find_package(Qt6 REQUIRED COMPONENTS Mqtt)
target_link_libraries(mytarget PRIVATE Qt6::Mqtt)
qmake: QT += mqtt

プロパティ

公開関数

QMqttMessage()
QMqttMessage(const QMqttMessage &other)
bool duplicate() const
quint16 id() const
const QByteArray &payload() const
QMqttPublishProperties publishProperties() const
quint8 qos() const
bool retain() const
QMqttTopicName topic() const
bool operator!=(const QMqttMessage &other) const
QMqttMessage &operator=(const QMqttMessage &other)
bool operator==(const QMqttMessage &other) const

詳細な説明

モジュール内部でMQTTメッセージが生成され、QMqttSubscription::messageReceived()シグナルを介して返されます。

プロパティのドキュメント

[read-only] duplicate : const bool

このプロパティは、メッセージが重複しているかどうかを示すものです。

重複メッセージとは、そのメッセージが以前に送信されているものの、まだ確認されていないことを示します。そのため、ブローカーはメッセージ自体の転送を確認するために再送信する必要があると判断します。重複メッセージが発生するのは、QoSレベルが1または2の場合に限られます。

アクセス関数:

bool duplicate() const

[read-only] id : const quint16

このプロパティには、メッセージのIDが格納されます。

IDは、QoSレベルが0より大きいメッセージに使用されます。

アクセス関数:

quint16 id() const

[read-only] payload : const QByteArray

このプロパティには、メッセージのペイロードが格納されます。

アクセス関数:

const QByteArray &payload() const

[read-only] qos : const quint8

このプロパティは、メッセージのQoSレベルを保持します。

アクセス関数:

quint8 qos() const

[read-only] retain : const bool

このプロパティは、メッセージがリテインされているかどうかを示します。

リテインされたメッセージは、将来のクライアントがサブスクライブできるよう、ブローカー上に保持されます。したがって、リテインされたメッセージは以前に作成されたものであり、ライブ更新ではありません。ブローカーは、トピックごとに1つのリテインされたメッセージしか保存できません。

アクセス関数:

bool retain() const

[read-only] topic : const QMqttTopicName

このプロパティには、メッセージのトピックが格納されます。

サブスクリプションでワイルドカードが使用されている場合、このサブスクリプションに一致するトピックを表します。このプロパティには、ワイルドカードは含まれません。

アクセス関数:

QMqttTopicName topic() const

メンバー関数のドキュメント

QMqttMessage::QMqttMessage()

新しいMQTTメッセージを作成します。

QMqttMessage::QMqttMessage(const QMqttMessage &other)

other のコピーである新しい MQTT メッセージを作成します。

QMqttPublishProperties QMqttMessage::publishProperties() const

メッセージの一部として受信したパブリッシュプロパティを返します。

注:この関数は 、パブリッシュメッセージを受信した際にのみプロパティを指定します。QoS値が1または2のメッセージは、メッセージがリリースされた際に追加のプロパティを含む場合があります。それらのプロパティは、QMqttClient::messageStatusChanged シグナルによって取得できます。

注:この関数は 、クライアントがQMqttClient::MQTT_5_0 をQMqttClient::ProtocolVersion として指定した場合にのみ、有効なデータを提供します。

bool QMqttMessage::operator!=(const QMqttMessage &other) const

メッセージとother が等しくない場合はtrue を返し、それ以外の場合はfalse を返します。

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

このオブジェクトをother のコピーにし、このオブジェクトの新しい値を返します。

bool QMqttMessage::operator==(const QMqttMessage &other) const

メッセージとother が等しい場合は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.