PySide6.QtMqtt.QMqttTopicFilter¶
- class QMqttTopicFilter¶
The
QMqttTopicFilterclass represents a MQTT topic filter.Details
QMqttTopicFilteris 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,QMqttTopicFilterprovides convenient functions related to topic filters likeisValid()ormatch().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
Synopsis¶
Methods¶
def
__init__()def
filter()def
isValid()def
match()def
__ne__()def
setFilter()def
swap()
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
- class MatchOption¶
(inherits
enum.Flag) This enum value holds the matching options for the topic filter.Constant
Description
QMqttTopicFilter.MatchOption.NoMatchOption
No match options are set.
QMqttTopicFilter.MatchOption.WildcardsDontMatchDollarTopicMatchOption
A wildcard at the filter’s beginning does not match a topic name that starts with the dollar sign ($).
- __init__(filter)¶
- Parameters:
filter –
QLatin1String
Creates a new MQTT topic filter with the specified
filter.- __init__(filter)
- Parameters:
filter –
QMqttTopicFilter
Creates a new MQTT topic filter as a copy of
filter.- __init__([filter=""])
- Parameters:
filter – str
Creates a new MQTT topic filter with the specified
filter.- filter()¶
- Return type:
str
Returns the topic filter.
See also
- isValid()¶
- Return type:
bool
Returns
trueif the topic filter is valid according to the MQTT standard section 4.7, orfalseotherwise.- match(name[, matchOptions=QMqttTopicFilter.MatchOption.NoMatchOption])¶
- Parameters:
name –
QMqttTopicNamematchOptions – Combination of
MatchOption
- Return type:
bool
Returns
trueif the topic filter matches the topic namenamehonoring the givenmatchOptions, orfalseotherwise.- __ne__(rhs)¶
- Parameters:
rhs –
QMqttTopicFilter- Return type:
bool
Returns
trueif the topic filterslhsandrhsare different, otherwise returnsfalse.- setFilter(filter)¶
- Parameters:
filter – str
Sets the topic filter to
filter.See also
- 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.- swap(other)¶
- Parameters:
other –
QMqttTopicFilter
Swaps the MQTT topic filter
otherwith this MQTT topic filter. This operation is very fast and never fails.