QtDesignStudio/QMLProjectFileFormat: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 3 users not shown)
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.
# Look out for any `..` and `content` entries. As you have modified the directory structure and names, these need to be adapted 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".
# Remove any CMakeLists.txt files as the export to QtCreator should be done with "File" -> "Export Project" -> "Enable CMake Generator".
# Modify the "ExamplesModel.qml" and "ExamplesModelV2.qml" inside of "examples/dataImports/DataModels/" to reflect the "qmlFileName" correctly after the changes.
# If project uses shaders, please add the following snippet to the qmlproject (please remember to change the UntitledProject3DContent/shaders/* path to the correct one) :
<syntaxhighlight lang="qml">
    ShaderTool {
        args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12"
        files: [ "UntitledProject3DContent/shaders/*" ]
    }
</syntaxhighlight>


=== 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
            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

Latest revision as of 12:57, 14 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. Look out for any `..` and `content` entries. As you have modified the directory structure and names, these need to be adapted throughout the project.
  5. 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.
  6. 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".
  7. For the files not listed in https://doc.qt.io/QtForMCUs-2.9/qtul-qmlproject-reference.html please use "Files" with "filter".
  8. Remove any CMakeLists.txt files as the export to QtCreator should be done with "File" -> "Export Project" -> "Enable CMake Generator".
  9. Modify the "ExamplesModel.qml" and "ExamplesModelV2.qml" inside of "examples/dataImports/DataModels/" to reflect the "qmlFileName" correctly after the changes.
  10. If project uses shaders, please add the following snippet to the qmlproject (please remember to change the UntitledProject3DContent/shaders/* path to the correct one) :
    ShaderTool {
        args: "-s --glsl \"100 es,120,150\" --hlsl 50 --msl 12"
        files: [ "UntitledProject3DContent/shaders/*" ]
    }

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