C
Working with UI Files
In Qt Safe Renderer, the safety-critical UI elements are implemented as QML Types. To include these to your application, we recommend you to add them to UI Files (.ui.qml). The UI files have some limitations that are also valid Qt Safe Renderer (for more information, see Constraints). Qt Design Studio automatically warns you if you use unsupported QML types or properties in your UI file.
You can use Qt Design Studio for designing an application UI that contains both safety-critical and non-safety elements in the .ui.qml files. This topic introduces the Qt Safe Renderer related functionality in Qt Design Studio.
UI Files in Qt Design Studio
Create a new UI file (.ui.qml file) in Qt Design Studio as follows:
- Select File > New File > Qt Quick Files > QtQuick UI File.
- Select Choose.
- In Component name, type the name for the component, that is, the .ui.qml file.
- Select Finish.
Add Qt Safe Renderer safety-critical QML types to the UI Files as follows:
- In Components, type safe (1) to the search field to find the Qt Safe Renderer components. Those should appear under QT SAFERENDERER (2).
- Drag and drop components to the 2D Design View (3).
- The QML code is automatically genereted to Code Design View.
import Qt.SafeRenderer
indicates you are using Qt Safe Renderer components on your application (4).
For more information how to use Qt Design Studio, see Qt Design Studio Manual.
Adding UI Files to Project
The Indicators example demonstrates how you can add UI files (.ui.qml) to your project in Qt Creator. When you add a new UI file, do as follows:
- In a CMake project, define the UI files in project's CMakeLists.txt file. For example:
set (safeqmls "MainForm.ui.qml" )
- In a qmake project, update the
SAFE_QML
variable in project file (.pro) with a path and name of your .ui.qml file. For example, if your UI file is under the Indicators example directory:SAFE_QML = $$PWD/MainForm.ui.qml $$PWD/MyTest.ui.qml
.
For detailed information, see Enabling Qt Safe Layout Tool.
You can add the UI files to your project's tree directory In Qt Creator as follows:
- In the Edit mode, select your application.
- In the context menu, select Add Existing Files and browse to your UI file.
- Select Open.
For more information about how to work with Qt Safe Renderer in Qt Creator, see Enabling Qt Safe Renderer in Project.
Available under certain Qt licenses.
Find out more.