I have a .json file in my project that looks as follows:
{
"ccu3":[
{
"PinName":"J1-13",
"PinDirection":"Input",
"PinType":"digital",
"System Function":"Park Lights"
},
{
"PinName":"J1-104",
"PinDirection":"Input",
"PinType":"analogue",
"System Function":"Hydraulic Temp"
},
{
"PinName": "J2-45" ,
"PinDirection":"Input",
"PinType":"tristate",
"System Function" : "Auto Greaser Pressure Sw"
}
]
}
I can extract "Pin Direction" and "PinType" from .json file as follows:
Text
{
text: jsonLoader.jsonObject["ccu3"][index]["PinDirection"]
color: "white"
font.pointSize: 10
}
Text
{
text: jsonLoader.jsonObject["ccu3"][index]["PinType"]
color: "white"
font.pointSize: 10
}
If 'PinDirection' is 'output' and 'PinType' is 'digital', I must display the PinName along with the Switch, else if 'PinDirection' is 'output' and 'PinType' is 'analogue', display Pin Name along with the Slider.
How do I make this conditional statement in QML? I'm also using the repeater to call the relevant .qml file for display.
My background is C and just started using QML. I only understand if else statement