How to bind multiple c++ values to qml properties?
-
Hey, I am currently working on a settings system for my application and I am having some problems binding Qml properties to the stored values on the C++ side. I hope someone here might have an idea on how to solve this problem elegantly.
I have one "Service" class that encapsulates a QSettings object, providing a "getSetting()" and "setSetting()" function and one "Controller" class that I register to QML to be able to write and read to/from the stored settings by accessing that "Service" class.
Now on my QML side, I'd like to bind each of my setting dependent properties to the corresponding setting, so that if I change a setting via. "setSetting(x)", my QML property is automatically updated.What are my possibilities here? Would I need to define a Q_PROPERTY for each and every setting I have (I have ~100+) and implement the get/set/notify function, or is there something else I could do?
Thanks for any help in advance.
-
I've come across QQmlPropertyMap and it seems to be a decent, dynamic solution to my problem.
-
C Creaperdown has marked this topic as solved on