[Interest] How to make conditional compilation in QML

Amit.2.Deshpande at continental-corporation.com Amit.2.Deshpande at continental-corporation.com
Fri Oct 10 11:04:00 CEST 2014


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
        }
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141010/3134dddd/attachment.html>


More information about the Interest mailing list