update only active qwidgets
-
Hi.
This is probably pretty basic, but I cannot find anything on this.
I have a lot of widgets, which are all set or read by a central datacenter. How do I do that best?
Do I need a signal/slot for each data item or should I have a getData()/setData() method in my datahandler.The widgets are on different screens, so I only need to update the ones, the user can actually see. Should I build a mechanism to tell the widgets, that they can now be seen and now have to update themselves from the datacenter or is there a clever way to disable slots that are out of view?
-
@Jakob-Clausen
This a pretty generic question, so i will just make a couple of observations.Qt slots cannot return a value. Therefore at minimum they are not suitable for a get-type function. So getters & setters are the usual way to access values.
I don't know exactly what you mean by "out of view". But there is nothing to stop you still getting/setting widget values which are not visible for whatever reason. It's not a terribly expensive operation (assuming you are just getting/setting an existing widget's value).
If you have a lot of widgets you might like to take a look at QDataWidgetMapper. This uses a model to achieve a two-way, getter-setter mapping between each widget and a single data item. You have to write code to map between a Qt model and whatever your "datacenter" presents as its data.
-
Ok. I'll have a look at that.
Thank you very much.