[Interest] Qml Combo box and model changed
jerome at bodycad.com
Wed Dec 10 17:11:57 CET 2014
I'm having some problem with i18n along with the ComboBox controls. Here's
something I'm doing with it:
model: [ qsTr("Choice A") + I18n.revaluate,
qsTr("Choice B") + I18n.revaluate ]
I used the i18n revaluation on a singleton to select current application
language (would do the same without it, if we change the model from a
When the language changed, here's what happen:
1. The list get it's values changed by changed on I18n (trigger
2. The combo box model changed.
3. the model look like a QQmlPropertyList, since it clear it and
repopulate it after
4. The model get clear, the current index goes back to 0
5. The new values are displayed but the current selection on all combo
box are reverted to the first entry.
I stated before, this also happen when assigning the model from a function.
Is there a way to prevent this or to hook ourself to keep the previous
value? I cannot used on modelChanged, since it would already imply the
value have changed (and cannot make sure the currentIndex is already
changed, since it's also done on the same signal).
The clear and assign of QQmlListProperty give us many problems everywhere
(performance wise with long list and things like this). I would love to see
a full copy assignation operator (along the append, clear, at, count). That
would be way faster and prevent problems like this, since the current index
would still be valid on changed. Suggestion out maybe use a QVariantList
instead for the model? not sure what it would imply underneath.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest