[Interest] QWidget + friends; How to restore properties across sessions?
bo at vikingsoft.eu
Sun Aug 17 07:46:02 CEST 2014
Den 16-08-2014 20:12, Mark Gaiser skrev:
> On Sat, Aug 16, 2014 at 10:37 AM, Christoph Feck <christoph at maxiom.de> wrote:
>> On Friday 15 August 2014 21:48:08 Mark Gaiser wrote:
>>> Now i'm searching for alternatives to this approach to prevent
>>> handling the bookkeeping myself and still have the same result. For
>>> instance, would it be possible to have some function (in QObject or
>>> QWidget i guess) where you either:
>>> - Define which properties should be saved/restored across sessions,
>>> bookkeeping would be done internaly.
>>> - or just some "QObject::persistentSettings(bool)" function that -
>>> when true - saves any properties and restores them upon next
>>> request in a persistent manner.
>> Each QMetaObject has a userProperty() which identifies the value that
>> the user can change in the object. To get a key for the settings file,
>> you can use special objectName()s. For example, in Smaragd, I prefix
>> any object that should have a persistent user property with "cm_" (for
>> config manager). See code at .
>> In Skulpture, there are two older versions of this file, one of them
>> uses QSettings instead of KConfigGroup. Those additionally
>> handle oddities with combo boxes, but they do not use userProperty().
> Hi Christoph,
> That is roughly the solution i'm looking for.
> But i'd like to go one step further. Do you know of some way - without
> editing the Qt source itself - to automatically pass each QWidget the
> gets constructed through the ConfigManager class? That would remove
> the need to add each GUI "manually" (in your case the Config UI main
> widget) in the ConfigManager.
There is no Qt way to do this. The dynamic invocation possibilities that
Qt add is in the areas of introspection, calling and identification.
Creation is not there.
Director, Viking Software.
Qt and C++ developers for hire
More information about the Interest