mxydsg8858
mxydsg8858

Reputation: 39

QML How could i set default option to null of combobox?

My combobox like this:

enter image description here

but i want this:

enter image description here

My combobox default is first currentText,but i don not want it show any thing when i have not pitch on noting. if i set:

displayText: " "

It doesn't work which one I choose. the value is null. what should i do?

Upvotes: 2

Views: 3088

Answers (2)

Paolo
Paolo

Reputation: 114

You can set currentIndex: -1:

ComboBox {
    currentIndex: -1
    model: [ ... ]      
}

Note: if it user be able to place own text put editable: true

Upvotes: 4

Mitch
Mitch

Reputation: 24386

If you just want an empty option, put an empty string in your model:

ComboBox {
    model: [
        "",
        "During transport",
        "Before cutting",
        "During cutting",
        "After cutting"
    ]
}

Upvotes: 2

Related Questions