O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling the sensor abstraction

To model the sensor abstraction, we create a project of type Qt Unit Test and add it as a subproject of entities.pro. The test class could be named entity_sensor. We won't be adding specific unit tests for the entity, but just check that it is working as intended within the use case. Feel free to add unit tests for the API that we'll be adding as an exercise.

By looking at use case broadcaster connects to sensor and broadcaster publishes sensor reading, we notice we need the following API:

  • An emitReading(QVariantMap) signal
  • A QVariantMap lastReading method to retrieve the last reading emitted for comparison purposes
  • A QString identifier method to retrieve the sensor's identifier

Also, we'll probably want ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required