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

SensorGlobal "TypeError: Object [object Object] has no method 'sensorTypes'"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.1.1
    • Sensors
    • None
    • Linux sensor plugin
    • e3e80980ca6a4628bf7a0dae61d9ab140913518c

    Description

      According to the documentation from https://qt-project.org/doc/qt-5.1/qtsensors/qml-qtsensors5-sensorglobal.html

      The following code should output a list of available sensors in a console

      import QtQuick 2.0
      import QtSensors 5.1
      import QtSensors 5.1 as Sensors
      
      Rectangle {
          width: 360
          height: 360
          Text {
              id: outTxt
              text: qsTr("Hello World")
              anchors.centerIn: parent
          }
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  Qt.quit();
              }
          }
      
          Accelerometer {
              active: true
              onReadingChanged: {
                  outTxt.text = "x: " + reading.x +
                           "\ny: " + reading.y +
                           "\nz: " + reading.z
              }
          }
      
          Component.onCompleted: {
              var types = Sensors.sensorTypes();
              console.log(types.join(", "));
          }
      
      }
      

      But instead I get a TypeError:

      TypeError: Object [object Object] has no method 'sensorTypes'

      Attachments

        Issue Links

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

          Activity

            People

              paeglis Gatis Paeglis
              paeglis Gatis Paeglis
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes