Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combobox with images

Tags:

qt

qml

qtquick2

Is it possible to create the ComboBox with images instead of strings? It doesn't support delegate:

ComboBox {
        currentIndex: 2
        model: ListModel {
            id: cbItems
            ListElement { imageHeight: 280; imageSource: "../images/tee3.png"  }
            ListElement { imageHeight: 300; imageSource: "../images/tee5.png"  }
            ListElement { imageHeight: 218; imageSource: "../images/tee1.png"  }
        }
        delegate: Image {
            height: imageHeight
            fillMode: Image.PreserveAspectFit
            source: imageSource
        }
        width: 200
    }
like image 401
Ivan Kush Avatar asked Nov 27 '25 10:11

Ivan Kush


1 Answers

You can maybe do it by defining you own ComboBoxStyle (here the documentation) and playing with the label field which is a Component.

like image 103
skypjack Avatar answered Nov 29 '25 23:11

skypjack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!