Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-69066

mqtt publish returns -1 in QML

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.11.2, 5.12.0 Alpha
    • 5.11.0
    • MQTT
    • None
    • Linux/X11, Windows
    • e023d5638bb29bb0c9b1b94ec4dde57d4b6af5ed

    Description

      When adding the publish method to main.qml in example: https://doc.qt.io/QtMQTT/qtmqtt-quicksubscription-example.html, a -1 (error) is returned.

       
      MqttClient {
              id: mqttclient
              port: 1883
              hostname: "localhost"
          }
       
          Button {
              id: connect
              text: qsTr("Connect")
              onClicked: {
                  console.log(mqttclient.connectToHost())
              }
          }

          Button {
              id: publish
               text: qsTr("publish")
              onClicked: {
                  console.log(mqttclient.publish("mytopic","mytestmessage"))
              }
          }
       
      As suggested by Maurice Kalinowsky, this is mostly caused by a failing auto-conversion from QString to QMqttTopicName.
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mkalinow Maurice Kalinowski
            eggn1n3 Rene Kogels
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes