Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm working on an ubuntu mobile app and I have a few questions about customizing a listview.

The listitem may contain an icon, but will have a title and subtitle.

What I'm having trouble with is that the thumbnail is pulled from the internet and I want to limit it's height and width.

Also, the title doesn't wrap if it's too long instead it just truncates and adds "..." at the end.

Thanks.

share|improve this question
add comment

1 Answer

As stated in the documentation for ListItem.Base (from which ListItem.Subtitle inherits):

icon : variant

The location of the icon to show in the list item (optional), or an Item that is shown on the left side inside the list item. The icon will automatically be anchored to the left side of the list item, and if its height is undefined, to the top and bottom of the list item.

You can provide you own image with specific width and height to be used as an icon.

ListView {
    [...]
    delegate: Subtitled {
        id: mySubtitledView
        text: 'Your text'
        subText: 'Your subtext'
        icon: Image {
            source: '<source_uri>'
            width: units.gu(5);
            height: units.gu(5);
        }
        height: units.gu(5)
    }
}

Note the height parameter set for Subtitled, as it will not grow automatically to fit the image's size.


As for your second question, I didn't find a "clean" way of formatting the text, but you can access directly to children of Subtitled and modify there. The main text seems to be the first children of the first children, so this will work:

       Component.onCompleted: {
            // Accessing Subtitled > Item > LabelVisual
            mySubtitledView.children[0].children[0].wrapMode = Text.Wrap
        }

This worked for me, but I don't know if it's a robust solution. Maybe others can comment.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.