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. Architecture for QML Sensor Application
Forum Update on Monday, May 27th 2025

Architecture for QML Sensor Application

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 247 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.
  • S Offline
    S Offline
    simmue
    wrote on 25 Mar 2019, 17:34 last edited by
    #1

    Hi all,

    at the moment I am working on a project on Raspberry Pi, where I have several sensors connected via i2c and want to show their values inside a Qt QML application.
    I abstracted the different sensor-types into respective Sensor-classes. Those classes also hold logic to ask for current values via i2c bus. They also hold the latest value.
    The sensor-objects live in one common, but separate Thread to decouple from UI.

    When a sensor-object did an update, it stores the latest value and then emits a signal that this very sensor updated its value.
    Then, an object ("SensorHub") in mainThread which is a custom QML type, gets one of its slots executed. (it has one slot for every sensor signal). In that slot I do two things:

    1. SensorHub has a member variable for every sensor value. That gets updated, or if the values are equal nothing is done.
    2. I emit another signal which can be seen by a JavaScript-Handler inside the QML-code to update the rendered values.

    Is this process correct or can I optimize it?
    It works, but I think it might be too much overhead to throw that many signals.

    All the signals that I use provide the new sensor value as parameter to the slot. Is this good practise or does it induce further overhead? Is there an alternative way to have the current sensor values available to the QML visualization?

    As I am a student I would be happy to hear tips, tricks and hints to get to learn more about Qt/QML!

    Have a nice day :-)

    1 Reply Last reply
    0

    1/1

    25 Mar 2019, 17:34

    • Login

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