02-11-2013 05:33 AM
Hi All,
I am curious to know about how to bind custom row with ListView and set row property(such as Level, ImageView,) dynamically with QML.?
02-11-2013 05:38 AM
I'm not sure what you mean. Do you mean you want to customize your listitem? Here is an example of QML code where I use an ImageView and stuff to customize everything.
ListView {
id: myList
leftPadding: 10
rightPadding: 10
dataModel: GroupDataModel { }
listItemComponents: [
ListItemComponent {
type: "item"
Container {
id: itemRoot
layout: DockLayout { }
Container {
topPadding: 20
bottomPadding: 20
leftPadding: 5
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Container {
topPadding: 15
ImageView {
imageSource: "asset:///images/myImage.png"
}
}
Container {
leftPadding: 15
layout: StackLayout { }
Label {
text: ListItemData.title
textStyle.fontSize: FontSize.Large
textStyle.lineHeight: 0.8
textStyle.color: Color.Black
}
Label {
text: ListItemData.subtitle
textStyle.fontSize: FontSize.Small
textStyle.color: Color.Gray
}
}
}
Container {
layout: DockLayout {}
verticalAlignment: VerticalAlignment.Bottom
horizontalAlignment: HorizontalAlignment.Center
preferredHeight: 2
preferredWidth: 800
background: Color.Black
}
}
}
]
}
If you meant something else, I'm happy to help if possible.
02-11-2013 05:40 AM - edited 02-11-2013 05:40 AM
I'm not sure if I get what you're after, but I think taking a look at the ListItemComponent might help you.
@Curahee Well played sir.
02-11-2013 05:49 AM
02-11-2013 05:54 AM
02-11-2013 05:59 AM
02-11-2013 06:09 AM
I add an own written QObject to the the groupdatamodel. The title and subtitle are just properties of that QObject. So if my property was called firstname, then the code would be ListItemData.firstname.
About the index of the listview position, I'm not sure about that. Tried a couple of things here but no succes yet. If I find something, I'll keep you posted.