Usage in Qbs¶
Here is a short example. Click on to see the explanation.
example/example.qbs
import qbs.FileInfo
CppApplication {
Depends {
name: 'Qt'
submodules: ['core', 'gui', 'qml', 'quick']
versionAtLeast: '6.5'
}
Depends { name: 'easy.qmldir' } // (1)!
name: 'easy-qmldir-qml-example'
Qt.qml.importName: 'easy.qmldir.example' // (2)!
Qt.qml.importVersion: '1.0' // (3)!
easy.qmldir.plugin: undefined // (4)!
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', // (5)!
'easy.qmldir.inputs' // (6)!
]
}
EasyQmldir { // (7)!
Qt.core.resourcePrefix: '/qt/qml/easy/qmldir/example/'
fileTags: ['qt.core.resource_data']
}
}
- 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
EasyQmldir
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: