QVariant weirdness with KUrl

David Faure faure at kde.org
Mon Apr 2 11:01:39 BST 2007


On Monday 02 April 2007, Andreas Pakulat wrote:
> Hi,
> 
> today I encountered that KConfigGroup can still not read/write KUrl
> entries. So I had a look and found something weird:
> 
> QVariant( KUrl( "file:///home/" ) ).type() == QVariant::Url
> 
> which means the above QVariant will return false on canConvert<KUrl>()
> and will return an empty string for value<KUrl>(). 
> 
> I guess the problem here is that KUrl subclasses from QUrl, but I'm of
> course not sure. Can somebody please look into this so
> KConfigGroup::readEntry( const char* pKey, const QVariant&) const; 
> can be adjusted accordingly to work with KUrl.
> 
> Meanwhile, here's a patch to allow KConfigGroup to read/write QUrl's
> using their string representation. Ok to commit?

Please never use QUrl::toString(), it breaks in some cases (e.g. paths with a '#' in them).
Use KUrl(theQUrl).url().

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list