Combo boxes have different values after selecting a value and when displaying choices
-
Hi all, I'm using the QMl combo box.
Different values after value selection and when displaying choices.Why are they different?
How can we get the same value?ListModel { id: listModel ListElement { name: "A & B" } ListElement { name: "&&&" } } ComboBox { id: comboBox textRole: "name" model: listModel } -
Hi all, I'm using the QMl combo box.
Different values after value selection and when displaying choices.Why are they different?
How can we get the same value?ListModel { id: listModel ListElement { name: "A & B" } ListElement { name: "&&&" } } ComboBox { id: comboBox textRole: "name" model: listModel }@Ren-K
They are different because&is used before a character to indicate it is a shortcut. That is why you get the underline character inA & B->A _B.I don't know QML, but in the first case you are in something which does not do shortcuts so it shows
A & Bliterally. In the second case it does accept shortcut key input and so displays with that information.Simplest would be if you can avoid
&characters in the texts altogether. Otherwise you will apparently have to do something to translate&to&&for the second case, which will be displayed as literal single&. How you do this from QML (do you need to go via script?) I do not know. -
@Ren-K
They are different because&is used before a character to indicate it is a shortcut. That is why you get the underline character inA & B->A _B.I don't know QML, but in the first case you are in something which does not do shortcuts so it shows
A & Bliterally. In the second case it does accept shortcut key input and so displays with that information.Simplest would be if you can avoid
&characters in the texts altogether. Otherwise you will apparently have to do something to translate&to&&for the second case, which will be displayed as literal single&. How you do this from QML (do you need to go via script?) I do not know.