[Interest] Strange ordering problem with ComboBox

Gian Maxera gmaxera at gmail.com
Mon Apr 11 11:36:00 CEST 2016


Hello,
I’m using the ComboBox item of QML with more than two Items with a ListModel like that:

	ComboBox {
		id: rateType
		anchors.horizontalCenter: parent.horizontalCenter
		width: parent.width*0.9
		Component.onCompleted: {
			if ( models.appointment.lead == null ) {
				rateType.currentIndex = 0
			} else if ( models.appointment.lead.type == 'contact' ) {
				rateType.currentIndex = 0
			} else if ( models.appointment.lead.type == 'brochure' ) {
				rateType.currentIndex = 1
			} else if ( models.appointment.lead.type == 'tentative' ) {
				rateType.currentIndex = 2
			} else if ( models.appointment.lead.type == 'definite' ) {
				rateType.currentIndex = 3
			}
		}
		model: 	ListModel {
			ListElement {
				leadType: 'contact'
				leadText: 'Contact only'
			}
			ListElement {
				leadType: 'brochure'
				leadText: 'Brochure request'
			}
			ListElement {
				leadType: 'tentative'
				leadText: 'Tentative lead'
			}
			ListElement {
				leadType: 'definite'
				leadText: 'Definite lead'
			}
		}
		textRole: "leadText"

But the popup menu appearing for select the option contain the elements into a different order than ListModel and when you select one of those the ComboBox select a different one. In such a way that it seems the index are correct but the labels of the popup menu are wrong.

Someone hits this error before ?

I’m using Qt 5.5 for now.

Ciao,
Gianluca.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160411/169ab9a5/attachment.html>


More information about the Interest mailing list