In a QML application I'm working one I have templates components files (stored in Templates) that I use in my screens files (stored in Screens). The folder structure is like this :
.
├── Templates/
│ ├── Buttons/
│ │ ├── ExampleButton.qml //reusable button
│ │ └── ...
│ ├── Text/
│ │ └── ExampleText.qml //reusable text
│ └── ...
└── Screens/
├── Menu1/
│ ├── Menu1_Screen1.qml
│ ├── Menu1_Screen2.qml
│ └── Menu1_Screen2/ (sub menu with list of sub screens you can access)
│ ├── Menu1_Screen2_A.qml
│ ├── Menu1_Screen2_B.qml //screen that uses ExampleButton.qml
│ └── ...
└── Menu2/
└── ...
When I want to include a template folder in a screen to use its templates, I do it with a relative path which makes the header of my QML file look like this :
import QtQuick 2.12
import QtQuick.Controls 2.12
import "../../../../../Templates/Buttons"
import "../../../../../Templates/Text"
import "../../../../../Templates/Pages"
import "../../../../../Templates/Miscellaneous"
Is there a classy way to define a global and absolute path to Templates and use it in my import statement like this ? (without having to use qmldir and define the content of every directory)
import "{$Templates}/Buttons"