Automatically incrementing unique ID for a QML items
-
Hello everyone!
I wonder about the best practices to use (implement) Automatically incrementing unique ID for QML items (if it's possible ofc). What I mean: let's suppose that there are different custom buttons in the whole project (in the different QML files and items). Every button should be connected to some c++ pointer. So I use C++ map, where the value is a pointer and the key is Q_ENUM. So I can manually set this Q_ENUM for each custom button and work with pointers via the mapping. Can this process be simplified or made more flexible? I thought about some static functions/variables in a QML singleton, but I'm not sure if this is a good practice. Moreover, I'm not sure, can it even be done correctly (as I suppose the QML items loading order is not strictly defined, so the unique IDs can be different within different program launches).