Changing single properties of children without knowing id
-
Hi,
I have a general question, motivated by my problem in https://forum.qt.io/topic/103394/using-subscripts-in-text-inside-combobox
If I use e.g. a
ComboBox
can I change a property in the combobox's contentItem (e.g. settingtextFormat = Text.RichtText
) without replacing the complete contentItem? The problem is, thatcontentItem
does not have an id which I can sue. -
You don't need an ID as long as you do have it's parent ID. Assuming that:
SomeItem { id: bob contentItem: Text { textFormat: Text.RichText } }
You should be able to do:
// Some JS function bob.contentItem.textFormat = Text.PlainText
In your case, you are attempting to modify an already displayed delegate, right? That is wrong, don't do it. Delegates are created and deleted on the fly, you should not relay on them in any way. If you need to modify the data or the way it is displayed, you should use your model for that, thus exposing data to your delegate so that it can adapt to it.
-
Yes, I am attempting to modify an already displayed delegate, setting the textFormat for a ComboBox or CheckBox. I thought if I do it in
Component.onCompleted
it would be OK, or not?Edit: I just tried your suggestion for a ComboBox, and it works perfectly, doing it inside
Component.onCompleted
.