[PATCH] Allow KConfigGroup to write any QVariant wrapped type

Andreas Pakulat apaku at gmx.de
Mon Mar 19 20:40:35 GMT 2007


On 19.03.07 20:51:09, Thiago Macieira wrote:
> Andreas Pakulat wrote:
> >while revisiting my KConfigXT patch I came across a problem, because
> >KConfigGroup uses the QVariant() constructor. This makes it (AFAICS)
> >impossible to use KUrl::List (for example) with writeEntry<> or
> >readEntry<>, at least I get a bunch of errors because there's no
> >QVariant constructor for that.
> 
> For any type that has a Q_DECLARE_METATYPE, I suggest adding the following 
> method to the class definition:
> 
>   inline operator QVariant() const { return qVariantFromValue(*this); }

Hmm, yeah that would work too and it would solve similar issues in other
places. 

Although I already committed, it can be easily reverted and this change
applied.

Currently I see Q_DECLARE_METATYPE used in kdelibs for:

KTextEditor::Document*
KUrl
KUrl::List (in my local copy due to adding UrlList to KConfigXT)
KJob*

I guess the pointer cases don't really qualify, or how should that look
like? I wonder why they are declared as metatype at all.

Andreas

-- 
Exercise caution in your daily affairs.




More information about the kde-core-devel mailing list