QtDesignStudio/QMLProjectFileFormat: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Update on the project structure change)
Line 1: Line 1:
=== With Qt Design Studio 4.5 the project structure did change. ===
=== With Qt Design Studio 4.5 the project structure did change. ===


With Qt Design Studio 4.5 we changed the project structue. The goal was to have only a single import path (./) at the root of the project. This is better in line with the QML compiler and QML tooling. (https://doc.qt.io/qt-6/qtqml-qtquick-compiler-tech.html)
With Qt Design Studio 4.5 we changed the project structure. The goal was to have only a single import path (./) at the root of the project. This is better in line with the QML compiler and QML tooling. (https://doc.qt.io/qt-6/qtqml-qtquick-compiler-tech.html). This also makes it so the relative URIs between modules are now the same in QDS and in the compiled C++ application.


==== Outline of changes ====


The default import path is now "./" the root folder of the project, since this better matches with the requirements of the QML compiler and tooling around QML.
* Before there were usually two import `imports` and "assets_imports".
Before there were usually two import "imports" and "assets_imports". Also relative URIs between modules are now the same in QDS and in the compiled C++ application.
* The default project module is now in ./ProjectName instead of imports/ProjectName.
* Assets are now imported to "Generated" instead of "assets_imports".
* QtQuick3D assets are now in Generated/QtQuick3D and Generated.Effects instead of e.g. assets_imports/QtQuick3DAssets.
* Because of the different import paths the (relative) URIs of resources like meshes are not the same when running the project in Qt Design Studio and the resulting C++ application. The solution is to either avoid referencing assets (files like .mesh files) between modules or moving to the new project structure.


The default project module is now in ./ProjectName instead of imports/ProjectName.
===Adjusting the project structure for legacy projects:===
One has to:


Assets are now imported to "Generated" instaed of "assets_imports".
# Move the project module from "./import/ProjectName" to "./ProjectName". The same applies to any other module in imports. The URI is not affected by this.
QtQuick3D assets are now in Generated/QtQuick3D and Generated.Effects instead of e.g. assets_imports/QtQuick3DAssets.
# Move all modules from "./assets_imports" to "./Generated". Adjust the import URIs throughout the project.
# Rename "./content" to "./ProjectNameContent". Adjust the import URIs throughout the project.
# Make sure that URIs in qmldir files match the directory structure, e.g. a qmldir defined in "./Generated/QtQuick3D/DangerArrow/qmldir" should be defined as "module Generated.QtQuick3D.DangerArrow". This is needed to ensure the same URIs between QDS and generated CMakeLists files. Ensure that import in .qml files match these URIs.
# Add missing filters to qmlproject. One has to make sure that all files in the subdirectories are effectively added to the project. This means that for a directory that contains QML and JavaScript files one has to define QMLFiles and JavaScriptFiles with this "directory".
# For the files not listed in https://doc.qt.io/QtForMCUs-2.9/qtul-qmlproject-reference.html please use "Files" with "filter".
# If project uses shared, please add the following snipped to the qmlproject:


Because of the different import paths the (relative) URIs of resouces like meshes are not the same when running the project in Qt Design Studio and the resulting C++ application.
The solution is to either avoid referencing assets (files like .mesh files) between modules or moving to the new project strucuture.


=== Adjusting the project strucuture for legacy projects: ===
An example of a Merge Request doing these changes is present here: https://git.qt.io/public-demos/qtdesign-studio/-/merge_requests/41
Move the project module from "./import/ProjectName" to "./ProjectName". The same applies to any other module in imports.
The URI is not affected by this.


Move all modules from "./assets_imports" to "./Generated". Unfortly this also requires adjusting the import URIs throughout the project.
===Project structure since Qt Design Studio 4.5:===
 
  ProjectName -                                   ### Folder containing the project
=== Project structure since Qt Design Studio 4.5: ===
  ProjectName -                                     ### Folder containing the project
             ProjectName                          ### Default QML module with the same name as the project
             ProjectName                          ### Default QML module with the same name as the project
             ContentProjectName                    ### Folder with the main QML files. Contains the project name, so it beomes unique, since in the C++ project this is a QML module
             ContentProjectName                    ### Folder with the main QML files. Contains the project name, so it becomes unique, since in the C++ project this is a QML module
             Generated                            ### Folder containing all generated QML modules from 3D import, content libarry and design systems
             Generated                            ### Folder containing all generated QML modules from 3D import, content library and design systems

Revision as of 11:49, 6 February 2025

With Qt Design Studio 4.5 the project structure did change.

With Qt Design Studio 4.5 we changed the project structure. The goal was to have only a single import path (./) at the root of the project. This is better in line with the QML compiler and QML tooling. (https://doc.qt.io/qt-6/qtqml-qtquick-compiler-tech.html). This also makes it so the relative URIs between modules are now the same in QDS and in the compiled C++ application.

Outline of changes

  • Before there were usually two import `imports` and "assets_imports".
  • The default project module is now in ./ProjectName instead of imports/ProjectName.
  • Assets are now imported to "Generated" instead of "assets_imports".
  • QtQuick3D assets are now in Generated/QtQuick3D and Generated.Effects instead of e.g. assets_imports/QtQuick3DAssets.
  • Because of the different import paths the (relative) URIs of resources like meshes are not the same when running the project in Qt Design Studio and the resulting C++ application. The solution is to either avoid referencing assets (files like .mesh files) between modules or moving to the new project structure.

Adjusting the project structure for legacy projects:

One has to:

  1. Move the project module from "./import/ProjectName" to "./ProjectName". The same applies to any other module in imports. The URI is not affected by this.
  2. Move all modules from "./assets_imports" to "./Generated". Adjust the import URIs throughout the project.
  3. Rename "./content" to "./ProjectNameContent". Adjust the import URIs throughout the project.
  4. Make sure that URIs in qmldir files match the directory structure, e.g. a qmldir defined in "./Generated/QtQuick3D/DangerArrow/qmldir" should be defined as "module Generated.QtQuick3D.DangerArrow". This is needed to ensure the same URIs between QDS and generated CMakeLists files. Ensure that import in .qml files match these URIs.
  5. Add missing filters to qmlproject. One has to make sure that all files in the subdirectories are effectively added to the project. This means that for a directory that contains QML and JavaScript files one has to define QMLFiles and JavaScriptFiles with this "directory".
  6. For the files not listed in https://doc.qt.io/QtForMCUs-2.9/qtul-qmlproject-reference.html please use "Files" with "filter".
  7. If project uses shared, please add the following snipped to the qmlproject:


An example of a Merge Request doing these changes is present here: https://git.qt.io/public-demos/qtdesign-studio/-/merge_requests/41

Project structure since Qt Design Studio 4.5:

ProjectName -                                    ### Folder containing the project
           ProjectName                           ### Default QML module with the same name as the project
           ContentProjectName                    ### Folder with the main QML files. Contains the project name, so it becomes unique, since in the C++ project this is a QML module
           Generated                             ### Folder containing all generated QML modules from 3D import, content library and design systems