Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Ambient Temperature Sensor
Forum Updated to NodeBB v4.3 + New Features

Ambient Temperature Sensor

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 233 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ananarsik
    wrote on last edited by
    #1

    Hello everyone!
    I am trying to work with the AmbientTemperatureSensor in Qt Qml for Android.
    I have just ran the Qt example called accelbuble(https://doc.qt.io/qt-5/qtsensors-accelbubble-example.html). And just added nexn code to the qml part:
    Rectangle {
    x:0
    y:0
    width:200
    height:200
    TextField {
    id: txt
    anchors.fill: parent
    text: (temp.reading ? temp.reading.temperature : "unknown")
    }
    }

    AmbientTemperatureSensor {
        dataRate: 100
        active: true
    
    
        id: temp
    
        onReadingChanged: {
            var t = (temp.reading ? temp.reading.temperature : "unknown");
            txt.text = t;
            console.log("Temp: ",t);
        }
        
    
    }
    

    But the program always write "unknown", even if i run it on real mobile phone.
    I am new to QML, so thanks for your answers!

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      It seems you are getting your technologies mixed up. The example you run is for the accelerometer (movement) but you are talking about a temperature sensor. Just adding bits of code is not going to make code run, there is a little more to it than that.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved