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.

Qt Creator provides a Qt Safe Renderer project template from Qt Creator 10.0.1 onwards. For more information, see Using Qt Safe Renderer Project Template in Qt Creator.

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

Enabling Localization

From Qt Safe Renderer 2.0 onwards, you can localize content on your safety-critical elements. To enable localization, you must define the following variables in the project (.pro) file:

VariableDescription
SAFE_LANGUAGES = <language code 1> <language code 2>List of language codes that your application supports. For example, SAFE_LANGUAGES = en fi.
SAFE_TRANSLATION = $$PWD/<translation file name>List of translation file names excluding the language code. For example, SAFE_TRANSLATION = $$PWD/safeui.
TRANSLATIONS += <translation file name>_<language code 1>.ts <translation file name>_<language code 2>.tsList of translation file names including the language code. There must be one file for each language listed in SAFE_LANGUAGES. For example, TRANSLATIONS += safeui_en.ts safeui_fi.ts.

Qt's lupdate tool extracts user interface strings from your application. lupdate reads your application's .pro file to identify which source files contain texts to be translated. This means your sorces files must be listed in the SOURCES or HEADERS entry in the .pro file. If your files are not listed the texts in them will not be found.

You can use an lupdate_only{...} conditional statement to specify the QML files that contain texts:

lupdate_only {
    SOURCES += SafeUI.qml
}

The following topics provide more information about localization in Qt:

See also the following topics:

Enabling Debug Information

You can get debug information for your safety-critical elements by adding the debug switch to the project file:

VariableDescription
SAFE_LAYOUT_EXTRA_PARAMS = -dDebug information is provided for the safety-critical elements.

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.

Using Qt Safe Renderer Project Template in Qt Creator

From Qt Creator 10.0.1 onwards, you can generate a new Qt Safe Renderer project by using a project template. First, you need to enable the Qt Safe Renderer plugin in Qt Creator as follows:

  1. Select Help > About Plugins.
  2. In Device Support, check SafeRenderer.

Generate the new Qt Safe Renderer project as follows:

  1. Select File > New Project > Application (Qt Safe Renderer).
  2. Select Choose.
  3. Follow instructions on the wizard to create a new project.

The generated project provides a base for your own Qt Safe Renderer project and its project file (.pro) contains the most important variables. You can build the project as instructed in Building the Qt Safe Renderer Project.

Available under certain Qt licenses.
Find out more.