DJ.Yosemite
DJ.Yosemite

Reputation: 315

QT,QTML How to add image Combobox list

I am using Qt Quitck Control 2.0 . I want to add image and text into Combobox list. Image is left , text is rigth. How to do that

Upvotes: 2

Views: 617

Answers (1)

derM
derM

Reputation: 13701

You write a custom delegate:

delegate: ItemDelegate {
    id: delegatRoot
    width: control.width
    height: 40
    Row {
        Image {
            width: delegateRoot.width / 2
            height: 40
            source: 'my/image/path.png'
        }
        Text {
            text: 'myText'
        }
    }
}

As in any view, you can use model.roleName to get the values from your ListModel.

Upvotes: 2

Related Questions