QtDesignStudio/FAQ: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Developing with Qt]]
{{Delete|reason=Empty. Content moved to [[QtDesignStudio/MCU_FAQ]].}}
{{LangSwitch}}
 
This page contains technical FAQs for Design Studio, its MCU support as well as Figma integration.
 
{|
| __TOC__
|}
 
 
 
 
 
==Design Studio & MCU==
 
===What are the main differences between Qt Quick and Qt Ultralite?===
There are several differences due to optimizations required by the embedded world. These include:
* Some QML types are unavailable in Qt Ultralite. The available types are listed [https://doc.qt.io/QtForMCUs-2.8/qtul-qmltypes.html here].
* Some of the types have additional constraints what is described [https://doc.qt.io/QtForMCUs-2.8/qtul-known-issues.html here].
* The QML/JS support is limited for MCU to the features described [https://doc.qt.io/QtForMCUs-2.8/qtul-javascript-environment.html here].
 
For full overview of the differences please refer to [https://doc.qt.io/QtForMCUs-2.8/qtul-qtquick-differences.html QtForMCUs docs].
 
===How to configure the MCU SDK in Design Studio?===
You can set it by navigating to ''Edit->Preferences->Device->MCU''. After setting it, please restart the Design Studio.
 
===I'm starting a project for MCU, what should I remember at the very beginning?===
You can start immediately and create a new project using the Qt for MCUs presets.
 
The components and their properties available in the Design Studio editor should respect the MCU rules.  However, if you plan to edit the QML code manually, you may end up creating code that is not valid for the MCU and you won't notice it at first glance.
 
In this case it is worth configuring Qt for MCUs SDK as mentioned in the previous question. The kit can be obtained from the Qt Maintenance Tool (an appropriate license is required). All you need to do is set the appropriate SDK installation path and reopen/create your project. With the MCUs SDK configured, Design Studio will automatically add an additional deployment step to your project that generates MCU-compliant C++ code. If something goes wrong during this process, such as using properties that are not available in Qt for MCU, you will see an error in the console.
 
For example, the following code for the Rectangle is perfectly fine, you can paste it into your MCU project in the Design Studio and run it:
<syntaxhighlight lang="qml">
Rectangle {
    width: 200
    height: 200
    visible: true
    anchors.centerIn: parent
    color: "red"
    rotation: 45
    border.width: 10
    border.color: "green" 
}
</syntaxhighlight>
 
However, a Rectangle type for MCU does not have ''border'' and ''rotation'' properties. If you configure the MCU SDK kit, you will see errors in the console and Design Studio won't be able to run the project/generate a preview:
{{WarningBox|text=/SomePath/SomeProject/Screen01.ui.qml:24:9: error: Group property of unknown type
 
border.width: 10
 
/SomePath/SomeProject/Screen01.ui.qml:23:9: error: Binding on property of unknown type
 
rotation: 45
}}
 
===I've created a new project for MCUs, and I see qmlprojectexporter warnings in the console. How do I get rid of them?===
This might happen despite configuring the MCU SDK properly.  Please let us know whenever such an issue arises and report a ticket [http://bugreports.qt.io/ here].
 
General information about qmlprojectexporter can be found at its dedicated [https://doc.qt.io/archives/QtForMCUs-2.7/qtul-qmlproject-reference.html page].
 
===I want to compile and/or deploy my application to MCU target in Qt Design Studio, how do I do that?===
 
You need to use Qt Creator for that, Design Studio does not support this workflow.
 
In Design Studio MCU project containing .qmlimport file needs to be created. It will contain CMakeLists.txt file that you can use to open Qt Creator project.
 
If instead you are in a regular Qt (non-MCU) project, you can enable CMakeLists file generation with ''File > Export Project > Enable CMake Generator''.
 
===I wanted to use <REPLACE_WITH_FEATURE> and Qt Ultralite complains that it is not available/supported, why?===
 
One has to be mindful that MCU kit is tailored for embedded devices, hence, some of its functionality has been limited to favor efficiency. This includes QML/JS functionalities that are described [https://doc.qt.io/QtForMCUs-2.8/qtul-javascript-environment.html here] and [https://doc.qt.io/QtForMCUs-2.8/qtul-qtquick-non-api-differences.html#script-expressions here]. In general, MCU JavaScript environment does not support:
* proprety var,
* property variant,
* functions,
* raw arrays (var arr = []) and JS container types like Array, Map, Set etc.,
* inline components,
* object literals.
 
Moreover, some types and their availability or how they work is different. This also differs between hardware targets. Please refer to the following sources:
* https://doc.qt.io/QtForMCUs-2.8/
* https://doc.qt.io/QtForMCUs-2.8/qtul-supported-platforms.html
* https://doc.qt.io/QtForMCUs-2.8/qtul-qtquick-differences.html
* https://doc.qt.io/QtForMCUs-2.8/qtul-overview.html
 
===I want to profile my application, how to do it?===
The documentation is available [https://doc.qt.io/QtForMCUs-2.8/qtul-performance-logging.html here], and [https://doc.qt.io/QtForMCUs-2.8/quickultralite-watch-example.html here] you can find a benchmark demo. Please note that benchmarking is meant for target devices and most of the metrics might not be implemented for desktop environments.
 
===Where are the project build files located?===
You can set the path to the build directory in the Qt for MCUs Deploy step. First you need to ensure that you have MCU SDK installed and set correctly in Design Studio.
 
Having the correct SDK, go to the ''Set runtime configuration for the project'' (cog icon in the bottom left corner) and under Deployment you will see Qt for MCUs Deploy Step, expand it and you will see the default build directory that you can change anytime.
 
===I added a new Qt Quick Control using ''File->New'' file but it doesn't work. What did I do wrong?===
Unfortunately, the distinction between regular Qt MPU and MCU is not yet well defined in Qt Design Studio.    The same set of files is available for MPU and MCU, however, it is not correct and will be adjusted in the future. To get the list of available types in Qt Quick Ultralite please refer to the [https://doc.qt.io/QtForMCUs-2.8/qtul-qmltypes.html docs].
 
 
 
 
==Qt Bridge for Figma export==
 
===I'm starting a project for MCU, what should I watch out for?===
MCU platforms have strict resource constraints (such as memory footprint, CPU usage). Because of this limitation, Qt Quick Ultralite was created, which is mostly compatible with Qt Quick, but you need to be aware of it's limitations. More details can be found [https://doc.qt.io/QtForMCUs-2.8/qtul-overview.html#compatibility-with-qt-quick here].
 
Qt Bridge for Figma makes it easier to create projects for the MCU and gives hints when unsupported features are used in the project. To see them, you need to load the plugin, go to ''Settings'' and set ''Export target'' to ''Qt for MCUs''.
 
Now, in the 'Home' tab you will see the 'MCU Compatibility' section, where useful tips will appear if unsupported usage is detected in the selected item, e.g.
[[File:Mcu compatibility warning stroke.png|left|thumb]]
 
 
 
 
 
 
 
 
===How to export Figma variables?===
Since version 4.6, Qt Bridge for Figma allows exporting Figma variables that are used to generate equivalent collections in QML on the Design System side.
 
The export is available for both targets (Qt and Qt for MCUs), however for MCUs it's still in the beta  stage (user must do some extra manual work, for details go to [https://wiki.qt.io/QtDesignStudio/FAQ#I've_imported_a_project_from_Figma_and_I_see_the_following_error_../Frame_1.ui.qml:3:1:_module_%22DesignSystem%22_is_not_installed._What_should_I_do? this question]).
 
To export variables, go to ''Qt Bridge -> Settings -> Advanced'' settings and check ''Export variables''.
 
Note that you need Design Studio 4.6 or newer for this to work.
 
 
 
 
==Design Studio import of data from Qt Bridge for Figma==
 
===I've imported a project from Figma and I see the following error ''../Frame_1.ui.qml:3:1: module "DesignSystem" is not installed''. What should I do?===
Full tooling for Design System import logic to MCU project have not been implemented yet. This is meant to be automated in the future. Nonetheless, you can easily integrate the generated files to your project by:
 
1. In the directory where the design system was generated one needs to create a ''DESIGN_SYSTEM_NAME.qmlproject''. For more information about ''.qmlproject'' please refer to the [https://doc.qt.io/archives/QtForMCUs-2.7/qtul-qmlproject-reference.html docs]. An example file could look like:
<syntaxhighlight>
// DesignSystem.qmlproject file
import QmlProject 1.3
Project {
    MCU.Module {
        uri: "DesignSystem"
    }
    QmlFiles {
        files: [
            "Collection1.qml",
            "Collection1Theme.qml",
            "Collection2.qml",
            "Collection2Theme.qml"
        ]
    }
}
</syntaxhighlight>
 
2. In your root project directory, one has to modify your ''PROJECT_NAME.qmlproject'' file by adding the entry that includes the generated module in your project. This could look like:
<syntaxhighlight>
// Somewhere in PROJECT_NAME.qmlprojec
ModuleFiles {
    files: [ "Generated/DesignSystem/DesignSystem.qmlproject" ]
}
</syntaxhighlight>
 
Also, you need to extend importPaths array:
<syntaxhighlight>
// Somewhere in PROJECT_NAME.qmlproject
importPaths: [ "imports" , “.”]  
</syntaxhighlight>
 
===I'm importing project from Figma and see weird bindings like: ''color: "DSPATH(VariableCollectionId:1:5$VariableID:7:21)"''===
You may potentially use any version of Qt Bridge for Figma plugin with any version of Qt Design Studio. However, that does not mean that they will be compatible.
 
You might encounter such entries at the bottom of the file if you are using outdated Design Studio, and newer plugin, where the first does not support the variables import that the latter exports.
 
In such cases it is always best to update both the plugin and Design Studio to their newest versions.
 
===How to distinguish MCUs from non-MCU projects in DS?===
The easiest way to know if the currently opened project is MCU or not is to inspect its ''PROJECT_NAME.qmlproject'' file. If the string ''QDS.qtForMCUs: true'' is present, then the project is in fact MCU project.
 
===Why is the Design System different for MPU projects vs. MCU projects?===
This is a limitation of the current Qt Quick Utralite. It doesn't support duck-typing, hence it cannot support nested QtObjects.
 
Therefore, for regular Qt Quick we have a QtObject-based Design System where all themes within a collection are defined within a single ''.qml'' file:
 
<syntaxhighlight lang="qml">
// Collection.qml
 
QtObject {
    property QtObject currentTheme: dark
    property QtObject strings: currentTheme.strings
    property QtObject colors: currentTheme.colors
    property QtObject dark: QtObject {
        property QtObject colors: QtObject {
            property color colors_background: Primatives.colors.colors_grey_1100
            property color colors_bad: Primatives.colors.colors_red_100
            property color colors_good: Primatives.colors.colors_green_100
        }  
        property QtObject strings: QtObject {
            property string strings_currentTheme: "Dark Theme"
        }
    }
    property QtObject light: QtObject {
        ...
    }
    ...
}
</syntaxhighlight>
 
The use in the project is as follows:
 
<syntaxhighlight lang="qml">
color: Collection.colors.colors_background
radius: Primatives.numbers.sizes_large_radius
</syntaxhighlight>
 
Design System for MCU is based on custom defined types, where each type has its own ''.qml'' file with definition. Hence, we have:
 
<syntaxhighlight lang="qml">
// CollectionTheme.qml
 
QtObject {
    property color colors_background: Primatives.currentTheme.colors_grey_1100
    property color colors_bad: Primatives.currentTheme.colors_red_100
    property color colors_good: Primatives.currentTheme.colors_green_100
    property string strings_currentTheme: "Dark Theme"
}  
 
 
// Collection.qml
 
QtObject {
    property CollectionTheme currentTheme: dark
    property CollectionTheme dark: CollectionTheme {
        property color colors_background: Primatives.currentTheme.colors_grey_1100
        property color colors_bad: Primatives.currentTheme.colors_red_100
        property color colors_good: Primatives.currentTheme.colors_green_100
        strings_currentTheme: "Dark Theme"
    }
    property CollectionThemelight: CollectionTheme {
        ...
    }
}
</syntaxhighlight>
 
As you can see, we don't have any property groups here (like colors, strings, etc.), so the usage is slightly different:
 
<syntaxhighlight lang="qml">
color: Semantics.currentTheme.colors_background
radius: Primatives.currentTheme.sizes_large_radius
</syntaxhighlight>
 
In both cases, the current theme can be changed using the ''currentTheme'' property in a particular collection.
 
===Can I have .js files in the project?===
No, you can't.
 
Qt Quick Ultralite subset of JavaScript runtime APIs. You can use JavaScript:
* In a body of property bindings.
* In a body of Signal handlers.
* In a definition of custom methods. However, be aware that many of the types are not supported (see [https://wiki.qt.io/QtDesignStudio/FAQ#I_wanted_to_use_%3CREPLACE_WITH_FEATURE%3E_and_Qt_Ultralite_complains_that_it_is_not_available/supported,_why?  this question]).
 
For more details please go to:
* https://doc.qt.io/QtForMCUs-2.8/qtul-qtquick-non-api-differences.html#script-expressions
* https://doc.qt.io/QtForMCUs-2.8/qtul-javascript-environment.html
 
===I get a warning when importing assets from Figma that the archive is not compatible with the current project type. What am I doing wrong?===
This warning was introduced in Design Studio 4.6. It appears when importing assets from Figma that have not been exported strictly for MCUs.
 
To get rid of the warning, go to ''Qt Bridge for Figma -> Settings'', set the export target to ''Qt for MCUs'' and export your project again.
 
Note: The 'Qt for MCUs' target was introduced in Qt Bridge for Figma 4.6.

Latest revision as of 08:59, 26 September 2024

This article is nominated for deletion. Reason: Empty. Content moved to QtDesignStudio/MCU_FAQ.
Please raise your support/opposition to this nomination in the article's discussion page.