C

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.

Including Qt Safe Renderer Modules

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:

ValueDescription
QT = qtsaferendererAdds the Qt Safe Renderer module to the project. The module is needed if project uses resource files.
QT = qsrplatformadaptationAdds 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:

ValueDescription
CONFIG += exceptionsException support is enabled.

Enabling Qt Safe Renderer Tools

By adding the following CONFIG value, you can enable both Qt Safe Layout Tool and Qt Safe Resource Compiler Tool in your project:

ValueDescription
CONFIG += qtsaferendererQt Safe Layout Tool and Qt Resource Compiler Tool are automatically enabled.

Note: You should still define the other variables related to the tools as described in Enabling Qt Safe Layout Tool and Enabling Qt Safe Resource Compiler Tool.

It is also possible to enable the tools separately as described in the next topics.

Enabling Qt Safe Layout Tool

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:

VariableDescription
CONFIG += qtsafelayouttoolAdds the Qt Safe Layout Tool's configuration to the project.

Note: If you have defined CONFIG += qtsaferenderer, Qt Safe Layout Tool is already added to your project.

SAFE_QMLA list of .ui.qml files that contain safety-critical QML types.
SAFE_LAYOUT_PATHA path where the generated safe layout data is saved.
SAFE_TARGET_FPSSets the frames per second value for Qt Safe Layout Tool. This can be also done via the -fps command line option. See Qt Safe Layout Tool.

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

Enabling Qt Safe Resource Compiler Tool

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:

VariableDescription
CONFIG += qtsafercctoolAdds the Qt Resource Compiler Tool's configuration to the project.

Note: If you have defined CONFIG += qtsaferenderer, the tool is already added to your project.

QT = qtsaferendererRequired if the project uses resource files. Includes the Qt Safe Renderer module.
SAFE_RESOURCESA list of .qrc files that contain resources.
SAFE_RESOURCE_FLAGSA list of flags for the Qt Safe Resource Compiler Tool.

For more information about the Qt resource system, see The Qt Resource System.

Adding Font Path to Project

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

Building the Qt Safe Renderer Project

After the project file (.pro) contains the Qt Safe Renderer specific definitions, you can build the project in Qt Creator with the following steps:

  1. Select Build > Run QMake. Running the qmake tool generates a folder that is defined in the SAFE_LAYOUT_PATH variable.
  2. 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_PATH variable 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.