Enabling Qt Safe Renderer in Project
In Qt Creator, you need to include your safety-critical UI elements into a Qt Quick project via .ui.qml files. The following topics describe how you can enable Qt Safe Renderer and its tools in your Qt Quick project (.pro file). For more information about the tools, see Qt Safe Renderer Tools.
Note: The Qt Safe Renderer Indicators example and its project file (indicators.pro) provide a simple example of most of the variables. You can use Indicators also in the host environment. For more information, see Indicators: Creating Safety-Critical UI.
With the QT variable, you specify which modules are included into your project. You should use only Qt Safe Renderer specific modules in the safety-critical applications. However, for testing purposes also Qt modules can be included.
The following Qt Safe Renderer specific modules are available:
|QT = qtsaferenderer||Adds the Qt Safe Renderer module to the project. The module is needed if project uses resource files.|
|QT = qsrplatformadaptation||Adds the platform adaptation to the project. That is, the event handler and the graphics API.|
The following CONFIG values specify common project configuration and compiler options for Qt Safe Renderer:
|CONFIG += exceptions||Exception support is enabled.|
|CONFIG += qtsaferenderer||Qt Safe Layout Tool and Qt Resource Compiler Tool are automatically enabled.|
It is also possible to enable the tools separately as described in the next topics.
Qt Safe Renderer renders the safety-critical UI elements on basis of the safe layout data that is provided to it. You can automatically generate the properly formatted safe layout data with Qt Safe Layout Tool. In order to enable Qt Safe Layout Tool in your Qt Quick project, you must define the following variables in the project (.pro) file:
|CONFIG += qtsafelayouttool||Adds the Qt Safe Layout Tool's configuration to the project.|
Note: If you have defined
|SAFE_QML||A list of .ui.qml files that contain safety-critical QML types.|
|SAFE_LAYOUT_PATH||A path where the generated safe layout data is saved.|
|SAFE_TARGET_FPS||Sets the frames per second value for Qt Safe Layout Tool. This can be also done via the |
Note: To achieve the same duration as defined in the QML description, the frames per second and the tick timer must match. The tick timer can be changed in ANIMATION_TIMER_TICK_IN_MS.
In the Qt Safe Renderer Indicators example's project file (indicators.pro), these variables are used as follows:
CONFIG += qtsaferenderer exceptions SAFE_QML = $$PWD/MainForm.ui.qml $$PWD/SecondaryForm.ui.qml SAFE_LAYOUT_PATH = $$PWD/../telltales/layoutData
The safety-critical UI elements can use resources defined in a resource collection file (.qrc) file. The resource collection file is useful if you need to embed safety-critical data assets into your application but you don't have a file system or you don't want to use the file system. With Qt Safe Resource Compiler Tool, you can generate Misra compliant data structures.
To enable Qt Safe Resource Compiler Tool in your Qt Quick project, you must define the following variables in the project (.pro) file:
|CONFIG += qtsafercctool||Adds the Qt Resource Compiler Tool's configuration to the project.|
Note: If you have defined
|QT = qtsaferenderer||Required if the project uses resource files. Includes the Qt Safe Renderer module.|
|SAFE_RESOURCES||A list of .qrc files that contain resources.|
|SAFE_RESOURCE_FLAGS||A list of flags for the Qt Safe Resource Compiler Tool.|
For more information about the Qt resource system, see The Qt Resource System.
To enable Qt Safe Renderer to find fonts, add the optional
SAFE_LAYOUT_FONTS variable to the project file. For more information, see Embedded Fonts.
SAFE_LAYOUT_FONTS = $$PWD/fonts
After the project file (.pro) contains the Qt Safe Renderer specific definitions, you can build the project in Qt Creator with the following steps:
- Select Build > Run QMake. Running the qmake tool generates a folder that is defined in the
- Select Build > Build Project <a project name>. Building the project generates the .srb, .srt, .srl, and .qpf2 files under the folder that the
SAFE_LAYOUT_PATHvariable defines. For more information about these files, see Generating Safe Layout Data.
To run the project, select Build > Run.
Available under certain Qt licenses.
Find out more.