[PyKDE] Another problem with custom widgets and pyuic4
Torsten Marek
shlomme at gmx.net
Mon Jan 16 17:17:18 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andreas Pakulat schrieb:
> Hi,
>
> Torsten this is for you:
>
> There is a problem setting various parameters on custom widgets, for
> example changing the sizePolicy in designer for a custom widget results
> in pyuic4 failing to generate the code with:
>
Hi Andreas,
even if it might sound ironically: the problem lies in your custom widget patch
(or my system of proxy Qt objects, depending on the pov). The thing is that the
special size policy methods belong to the proxy QWidgets, not the proxy QObjects
(see uic/Compiler/qtproxies.py). Thus, the default base class for custom widgets
has to be QWidget and not QObject. BTW, how do you manage to get these classes
anyway? I can't find that in Qt Designer, all I know is the "promote to custom
widget" function.
Technical details follow:
The code of the custom widget is indeed not executed (not even imported) in this
case, but a type is generated on the fly (at least when the UI is converted to
code), via
new_type = type("PersonWidget", (baseclass_type,) , {module:""})
with baseclass_type normally being the class that is enclosed in the <extends />
tag of a <customwidget />. If baseclass_type is qtproxies.QObject, the special
proxy method (special in the way that it needs an extra implementation, in
contrast to a method like widget.setText("foobarbaz"), which can be handled via
__getattribute__) sizePolicy(self), returning a proxy object of QSizePolicy,
does not exist.
If all the talking about proxy objects make your head buzz and you ask yourself
why this is necessary, just consider that both UI loader and compiler share most
of the code. Of the ~920 SLOCS, only 325 are special to the compiler and 43 to
the loader.
greetings
Torsten
- --
Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146 894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDy9UefMVFHqJEyFgRAiT0AJ4qmMySCO/MrDYD/aHHu4897VfB8wCfaFwR
LMq6JCbpnPMeqs3/dEa6KVw=
=+INM
-----END PGP SIGNATURE-----
More information about the PyQt
mailing list