Usage in Qbs¶
Here is a short example. Click on to see the explanation.
example/example.qbs
import qbs.FileInfo
import easy as Easy // (1)!
CppApplication {
Depends {
name: 'Qt'
submodules: ['core', 'gui', 'qml', 'quick']
versionAtLeast: '6.5'
}
Depends { name: 'easy.qmldir' } // (2)!
name: 'easy-qmldir-qml-example'
Qt.qml.importName: 'easy.qmldir.example' // (3)!
Qt.qml.importVersion: '1.0' // (4)!
easy.qmldir.plugin: undefined // (5)!
Group {
name: 'C++ files'
prefix: 'src/'
files: ['**/*.cpp', '**/*.hpp']
}
Group {
name: 'QML files'
files: ['**']
prefix: 'qml/'
Qt.core.resourceSourceBase: 'qml/'
Qt.core.resourcePrefix: '/qt/qml/'
fileTags: [
'qt.core.resource_data', // (6)!
'easy.qmldir.inputs' // (7)!
]
}
Easy.Qmldir { // (8)!
Qt.core.resourcePrefix: '/qt/qml/easy/qmldir/example/'
fileTags: ['qt.core.resource_data']
}
}
- Import
easy
items under some name. I preferEasy
. - Add a dependency on the
easy.qmldir
module in your product. - Don't forget to set the module name via
Qt.qml.importName
. - Set the module version using
Qt.qml.importVersion
. - In this case, the product is not a QML engine extension but an application, so there is no plugin. Disable generation by setting it to
undefined
. - Tag with
qt.core.resource_data
to pack QML-files into Qt resources. - Tag with
easy.qmldir.inputs
to list the QML-files in the generatedqmldir
. - You can use
easy.Qmldir
item to easily grab the generatedqmldir
for further packing into resources (like here) or, for example, for installation viaqbs.install: true
.
You can run this example yourself! Just go to the module’s root folder and execute:
Output¶
The resulting qmldir
looks like this: