[Kde-bindings] KDE::ConfigGroup unable to read and read a font config entry in korundum

Stefano Crocco stefano.crocco at alice.it
Fri May 1 17:01:04 UTC 2009


I just found this issue: I have a config file, created with KDE::Config, which 
contains a font entry. When I try to read it back, however, it fails saying 
"KConfigGroup::convertToQVariant: unhandled type". Reading a QFont, however, 
should be supported, as the documentation for KConfigGroup says and a quick 
test using C++ confirms.

Here's some code which shows this behaviour.

I just found out that in korundum, trying to read or write entries of type 
font in a configuration file using KDE::ConfigGroup#read_entry and 
KDE::ConfigGroup#write_entry doesn't work, while it works from C++ (and I 
think the documentation clearly states it should work).

Here's a simple script which demonstrates what I mean:

require 'korundum4'
data = KDE::AboutData.new "test", "", KDE::ki18n("test"), "0.0.0"
KDE::CmdLineArgs.init [], data
app = KDE::Application.new

cfg1 = KDE::Config.new '/tmp/test_write', KDE::Config::SimpleConfig
cfg1.group('Test').write_entry 'Test font', KDE::Application.instance.font
cfg1.sync
cfg2 = KDE::Config.new '/tmp/test_read', KDE::Config::SimpleConfig
font = cfg1.group('Test').read_entry 'Test font', Qt::Font.new

I also attach a test file with a font entry to test the read method. As you 
can see running this code, both writing and reading the font entry fail. The 
error while reading is:

KConfigGroup::writeEntry: KConfigGroup::writeEntry - unhandled type  in group 
"Test"

while the error while reading is:

KConfigGroup::convertToQVariant: unhandled type

Am I missing something?


Another question: is there a way to have Qt::Variant#value return the value 
converted to another type? In C++, for example, you can write this:

QVariant v(10);
QString str = v.value<QString>();

I think korundum usually deals with templated method by having an additional 
parameter with the name of the class. However, if I try to do that with 
Qt::Variant#value, I get :

ArgumentError: wrong number of arguments (1 for 0)

Is there another way to do this?

Thanks in advance

Stefano
-------------- next part --------------
[Test]
Output Font=Courier 10 Pitch,10,-1,5,50,0,0,0,0,0


More information about the Kde-bindings mailing list