Folks,
I’m an experienced developer though mostly not in Qt. I am curious as to what structure you would use for the data set in a preferences dialog. For example:
The prefs dialog is a long-lived object that can be queried for values, essentially globally;
The prefs dialog is short-lived, initialised from and changes another class/object that can be queried by other program code;
The prefs dialog is short-lived, initialised from code in the main program that reads prefs from other objects into it, displays the dialog, then writes changes back to other (multiple) objects;
The prefs dialog is short-lived, reads values from some global source – e.g QSettings – and writes back there. Other parts of the program always read from the same source;
and many others are I possible…
I have seen and implemented several of these and never felt that it was necessarily the “best” way. For example:
The first two ways both split many values (with types that are perhaps not otherwise global) into an object and away from the place they are primarily used. The second way, while seeming to split view from data “properly”, also adds to the code that must be maintained although there may be offsetting advantages.
The third option just invites mistakes of failure to update the prefs setter/getter code properly with changes to the objects. The final way also suffers from that, but also means the translation from QSettings (etc) format to internal format is done in many places and can get out of sync.
Any thoughts?
↧