Reputation: 10584
I add a property cond in Row element,so when cond is true, it will draw 3 picture,otherwise only one will be drawed
but qml report "Unexpected token `if'" ,any ideas? Thanks
import QtQuick 1.1
Rectangle{
id:rect
property bool cond:true;
Row{
Image{ source:"good.png" }
if(cond) {
Image{ source:"good.png" }
Image{ source:"good.png" }
}
}
}
Upvotes: 2
Views: 1450
Reputation: 2243
Your code is syntactically wrong: QML structure description statements cannot be wrapped in javascript code.
But the solution is simple:
import QtQuick 1.1
Rectangle {
id:rect
property bool cond: true;
Row{
Image{ source:"good1.png" }
// show image elements only if 'cond' is true
Image{ source:"good2.png"; visible: cond }
Image{ source:"good3.png"; visible: cond }
}
}
Alternatively you can create the image elements dynamically, but this is more complex.
Upvotes: 4