[PyQt] QSettings.registerFormat unavailable in PyQt4?
Giovanni Bajo
rasky at develer.com
Sat Jun 6 01:56:55 BST 2009
On Sat, 6 Jun 2009 01:19:39 +0200, David Boddie <david at boddie.org.uk>
wrote:
> On Fri Jun 5 19:25:01 BST 2009, Giovanni Bajo wrote:
>
>> On 6/4/2009 10:18 PM, Phil Thompson wrote:
>
>> > It can't be wrapped because of the nature of the function pointer
>> > arguments - bad API design.
>>
>> Is it the same with Jambi?
>
> I think so - look here:
>
>
http://doc.trolltech.com/qtjambi-4.5.0_01/com/trolltech/qt/core/QSettings.html
Given that there is no way to unregister a format, I think that there is a
way to wrap it for PyQt: just prepare a fixed number of clones of global
read/write functions, that retrieve Python's callable objects from a
fixed-size global array. Each time registerFormat() is used, save the read
and write function callables into the global arrays (incref'ing them
forever, and using an ever growing counter that says how many custom
formats have been registered); then, call the C++ version and pass it the
pointers to the correct couple of clones of the global read/write
functions.
I hope the above makes sense; otherwise I'll try to write some pseudo-code
:)
> Incidentally, one of my colleagues recently had to document the use of
> QSettings::registerFormat(). Although QSettings was made extensible in
> Qt 4.1, it doesn't seem to be a feature that many people try to use,
> perhaps because some things in the documentation were previously unclear.
Well it's also not something that's badly needed. QSettings already
supports all native formats and ini files, and most people are fine with
either of these options.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
More information about the PyQt
mailing list