QMqttTopicFilter#

The QMqttTopicFilter class represents a MQTT topic filter. More

Inheritance diagram of PySide6.QtMqtt.QMqttTopicFilter

Synopsis#

Functions#

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

Detailed Description#

QMqttTopicFilter is a thin wrapper around a QString providing an expressive data type for MQTT topic filters. Beside the benefits of having a strong type preventing unintended misuse, QMqttTopicFilter provides convenient functions related to topic filters like isValid() or match() .

For example, the following code would fail to compile and prevent a possible unintended and meaningless matching of two filters, especially if the variable names were less expressive:

QMqttTopicFilter globalFilter{"foo/#"};
QMqttTopicFilter specificFilter{"foo/bar"};
if (globalFilter.match(specificFilter)) {
    //...
}

The usability, however, is not affected since the following snippet compiles and runs as expected:

QMqttTopicFilter globalFilter{"foo/#"};
if (globalFilter.match("foo/bar")) {
    //...
}

See also

QMqttTopicName

class PySide6.QtMqtt.QMqttTopicFilter(filter)#

PySide6.QtMqtt.QMqttTopicFilter([filter=””])

Parameters:

filterPySide6.QtMqtt.QMqttTopicFilter

Creates a new MQTT topic filter as a copy of filter.

Creates a new MQTT topic filter with the specified filter.

PySide6.QtMqtt.QMqttTopicFilter.MatchOption#

(inherits enum.Flag) This enum value holds the matching options for the topic filter.

Constant

Description

QMqttTopicFilter.NoMatchOption

No match options are set.

QMqttTopicFilter.WildcardsDontMatchDollarTopicMatchOption

A wildcard at the filter’s beginning does not match a topic name that starts with the dollar sign ($).

PySide6.QtMqtt.QMqttTopicFilter.filter()#
Return type:

str

Returns the topic filter.

See also

setFilter()

PySide6.QtMqtt.QMqttTopicFilter.isValid()#
Return type:

bool

Returns true if the topic filter is valid according to the MQTT standard section 4.7, or false otherwise.

PySide6.QtMqtt.QMqttTopicFilter.match(name[, matchOptions=QMqttTopicFilter.MatchOption.NoMatchOption])#
Parameters:
Return type:

bool

Returns true if the topic filter matches the topic name name honoring the given matchOptions, or false otherwise.

PySide6.QtMqtt.QMqttTopicFilter.__ne__(rhs)#
Parameters:

rhsPySide6.QtMqtt.QMqttTopicFilter

Return type:

bool

Returns true if the topic filters lhs and rhs are different, otherwise returns false.

PySide6.QtMqtt.QMqttTopicFilter.setFilter(filter)#
Parameters:

filter – str

Sets the topic filter to filter.

See also

filter()

PySide6.QtMqtt.QMqttTopicFilter.sharedSubscriptionName()#
Return type:

str

Returns the name of a share if the topic filter has been specified as a shared subscription. The format of shared subscriptions is defined as $share/sharename/topicfilter.

PySide6.QtMqtt.QMqttTopicFilter.swap(other)#
Parameters:

otherPySide6.QtMqtt.QMqttTopicFilter

Swaps the MQTT topic filter other with this MQTT topic filter. This operation is very fast and never fails.