Selecting QML items from a group
-
I'm having trouble figuring out the best way to implement a UI that I want in my program. The basic idea is that there are two groups consisting of custom QML items. The user will select one of the items from the first group, resulting in that item being highlighted, and then when they click on an item from the second group, a javascript function is executed that does some processing based on certain properties of those items.
Here's the issues I'm running into. First, I have a "selected" state in the QML items, that I can have them switch to when clicked on. But at the same time, I need the previously selected item to go out of its selected state. It seems like I won't be able to have this logic in the individual QML item, so I'll need it in the container for the items. I'm not sure the best way to set it up, though.
I'll also need to store the selected QML item, so it can be passed to a javascript function. How can I do that? Is it as easy as "property variant selectedItem" and then setting that equal to the id of whatever item is selected? Then can I just pass that as an argument to a javascript function and call selectedItem.myProperty to access the data?