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

Documentation of Qt WebChannel JavaScript API is incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 5.15
    • 5.12.6
    • WebChannel
    • None
    • Windows

    Description

      I tried to connect on property changes of a QtObject defined in QML and registered in the WebChannel. The documentation (https://doc.qt.io/qt-5/qtwebchannel-javascript.html) says to follow the QML style like:

      // To get notified about remote property changes,
      // simply connect to the corresponding notify signal:
      foo.onMyPropertyChanged.connect(function(newValue)  

      {     console.log(newValue); }

      );

      However I found out eventually, by looking in the source code of qwebchannel.js, that the following convention is used:
      notifySignalData[0] = propertyName + "Changed";

      Without the "on" and capitilized first character. After figuring this out, the second problem is that the parameter in the callback (newValue) is always undefined. Maybe this is intended and the workaround or (actualy intended workflow?) is to read the updated property directly.

      Please update the documentation to avoid unneeded debugging issues.

      Attachments

        For Gerrit Dashboard: QTBUG-81782
        # Subject Branch Project Status CR V

        Activity

          People

            milianw Milian Wolff
            jeroen_o Jeroen Oomkes
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes