Sample Qt Application - mainApp


Note

Updated files may be downloaded from Reach Technology.

Load The Sample Project - mainApp

The screen should look like this.

../../_images/mainApp.png

mainApp in Qt Creator

Let’s look at the project structure. First, both the Headers and Sources directories contain sub-directories with /data/app/common roots. These sub-directories contain common .cpp and .h files that contain hardware related code and definitions - drivers of a sort for the G3 module hardware.

There are two files of note inside the Sources directory:

  • myGlobal.cpp

  • myStyle.cpp

These two files each create a QQmlPropertyMap. As such they are global in nature (spanning cpp and QML as well) and hold all system variables that are needed for external access. In particular, these property maps are used to store key/value pairs that are displayed (i.e., temperature, RPM, etc) or affect the display (i.e., display color for a text box, text size, background color, etc).

Each key is a unique, user defined name. Values can be sent over a communications interface triggering automatic display updates.

For example, using the serial interface, if you send

themeDark=true

then the background color and text colors are changed to the dark theme color set.

Todo

(Mark) Need to add code snippets and explanations of how property map, signals and serial comms are hooked up and function.

The testing approach to take from a console only perspective is as follows1:

  • In the Reach Technology G3 Developer VM run mainApp from Qt Creator.

  • Open a terminal and run picocomm for the debug interface. Using the shell alias, the command line is com0.

  • Open another terminal. We will use this terminal to pipe test stimulus data to the RS-232 device.

  • In the second terminal window (in the home directory) type cat main.txt > /dev/ttyUSB1.

  • Now type cat main2.txt > /dev/ttyUSB1. Watch the screen colors change.

  • Repeat the cat main.txt > /dev/ttyUSB1 command. Lather, Rinse, Repeat as you wish.

From here, explore the capabilities of myGlobal and myStyle.

All Reach Technology sample Qt applications are based on this Property Map paradigm. It is very powerful.


Footnotes:

1

For this example, we assume:

  • the debug interface is accessed from the Reach Technology G3 Developer VM via /dev/ttyUSB0; on target this port is /dev/ttymxc0.

  • the RS-232 port on the “Y” cable is accessed from the Reach Technology G3 Developer VM via /dev/ttyUSB1; on target this port is /dev/ttymxc1