Yeah I agree. You don't fully grasp yet how QML works. We all had that time when we are starting especially when coming from non-declarative language š You should really try reading a bit even just the basics of it. One key thing is that Javascript is used for logic within QML, ideally only for front end logic but you could also do everything with just QML and JS.
For your example, you can simply add an inline conditional statement for the icon.name property. Or for more advanced use especially if you intend to add more changes, you can use States.
Here's a sample one for the inline:
icon.name: switch.checked ? "tick" : "close"