Hi,
I'm having an issue where I need to draw a different colored Rectangle based on a condition. OR better yet is it possible to use 2 different delegates?
So for instance
if for instance I get a value from the model such as "active" then the rectangle I should create should be green.
If I get "not active" the rectangle will look different.
THe problem is I don't know how I can use an if condition in the delegate. Currently I have:
ListView {
id: calendarListView
x: 7
y: 96
width: 587
height: 418
model: callsonholdModel
delegate:
Rectangle {
id: calendarCellHolder
height: 124
border.width: 2
border.color: "#CFCFCF"
width: calendarHeader.width
//HERE IS WHERE I NEED TO DECIDE WHAT RECTANGLE TO DRAW. CURRENTLY ITS JUST DRAWING ALL THE SAME RECTANGLE.
Rectangle {
id: activeMeetingRect
width: calendarHeader.width - 30
height: 84
radius: 9
anchors.top:calendarCellHolder.top
anchors.right: calendarCellHolder.right
anchors.left: calendarCellHolder.left
anchors.topMargin: 20
anchors.bottomMargin: 20
anchors.leftMargin: 15
anchors.rightMargin: 15
gradient: Gradient {
GradientStop {
position: 0
color: "#5ffb26"
}
GradientStop {
position: 1
color: "#000000"
}
}
ListView {
id: calendarListView
x: 7
y: 96
width: 587
height: 418
model: callsonholdModel
delegate:
Rectangle {
id: calendarCellHolder
height: 124
border.width: 2
border.color: "#CFCFCF"
width: calendarHeader.width
//HERE IS WHERE I NEED TO DECIDE WHAT RECTANGLE TO DRAW. CURRENTLY ITS JUST DRAWING ALL THE SAME RECTANGLE.
Rectangle {
id: activeMeetingRect
width: calendarHeader.width - 30
height: 84
radius: 9
anchors.top:calendarCellHolder.top
anchors.right: calendarCellHolder.right
anchors.left: calendarCellHolder.left
anchors.topMargin: 20
anchors.bottomMargin: 20
anchors.leftMargin: 15
anchors.rightMargin: 15
gradient: Gradient {
GradientStop {
position: 0
color: "#5ffb26"
}
GradientStop {
position: 1
color: "#000000"
}
}
To copy to clipboard, switch view to plain text mode
EDIT: I actually just found out I could wrap the Rectangle's with a component { id: Delegate1 Rect{...} } component { id: Delegate2 Rect{...} }
so really I just need to see if I can use an if/else inside the delegate to switch between Delegate1 and Delgate2.
Thanks
Bookmarks