[Interest] Best practices for settings

Ben Lau xbenlau at gmail.com
Sun Nov 17 18:02:20 CET 2013


On 17 November 2013 21:53, Tim Hoffmann <thoffmann at texstudio.org> wrote:

> Hi all,
>
> Are there any best practices for working with QSettings in larger
> projects with many settings?
>
> In particular:
> - How do you efficiently synchronize settings with widgets in an options
> dialog.

- How do you efficiently detect changes made in an option dialog. (I
> have some options that need significant calculations after changing.
> These should only be triggered if the corresponding setting was actually
> changed.)
>

Usually a setting class is a simple data model without complication logic
or any calculation.

As now you need to interact with the Option dialog and there has
calculation after changing value,
it looks pretty like an example usage of MVVM. Unfortunately that Qt do not
provide MVVM implementation by
default. I think people usually use QObject with custom property then watch
for its change by DynamicPropertyChange event.


> - How do you access the settings in the source code? Always casting the
> QVariants seems a bit tedious but the alternative would be to have
> additional local variables (or members) for the values which you would
> have to maintain additionally.
>
> Thanks in advance.
>
> Tim
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131118/95594144/attachment.html>


More information about the Interest mailing list