[Interest] How to make conditional compilation in QML
Kristoffersen, Even (NO14)
Even.Kristoffersen at Honeywell.com
Fri Oct 10 11:14:57 CEST 2014
If I read your email correctly it would probably be better solution for your problem to have a single Loader and only load the model specified in the config file?
Loader {
id: 3DModel
source: getModelFile() // Loads the corresponding QML file for the configured model
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
function getModelFile()
{
if (config === "QML1") return "3D/File1.qml";
else if (config === "QML2") return "3D/File2.qml";
etc.
}
}
-Even
From: interest-bounces+even.kristoffersen=honeywell.com at qt-project.org [mailto:interest-bounces+even.kristoffersen=honeywell.com at qt-project.org] On Behalf Of Amit.2.Deshpande at continental-corporation.com
Sent: 10. oktober 2014 11:04
To: Interest at qt-project.org
Subject: [Interest] How to make conditional compilation in QML
Hello,
I am using 5 different 3D models on my display. Each model is a seperate QML file.
These models are loaded as below using the Loader. At any given time there can be only one model enabled.
The enabling is done prior to compilation.
Please suggest me how can I compile only one of the 5 different QML files that are available in the project.
There is a configuration XML file in which either of the ids are chosen i.e from QML1 to QML 5.
I was thinking of doing a conditional compilation based on the model that is being selected, but I do not know how it is done in QML..
Config XML file as below//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<3d>
<model>QML2</model>
<!-- QML1/ QML2/ QML3/ QML4/ QML5-->
</3d>
Loader Code used in QML as below/////////////////////////////////////////////////////////////////////////////////////////////////7
Loader{
id: QML1
source: "3D/File1.qml" // Loads the corresponding QML file
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
}
Loader{
id: QML2
source: "3D/File2.qml"
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
}
Loader{
id: QML3
source: "3D/File3.qml"
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
}
Loader{
id: QML4
source: "3D/File4.qml"
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
}
Loader{
id: QM5
source: "3D/File5.qml"
asynchronous: true
active: model
onLoaded: {
origX = item.x
origY = item.y
origZ = item.z
file.modelLoaded = true
}
}
More information about the Interest
mailing list