[PyKDE] PyQt4: Promoting a custom widget in qt4 designer

Andreas Pakulat apaku at gmx.de
Mon Dec 4 12:53:02 GMT 2006


On 06.12.06 13:37:39, Sebastian Kügler wrote:
> On Monday 04 December 2006 11:23, Andreas Pakulat wrote:
> > On 04.12.06 03:38:47, Eriol wrote:
> > > I'm trying to use custom widget promotion in qt4 designer. I attach an
> > > example of what I'm doing: what's wrong with it?
> > > I have searched for documentation about this, but I didn't find anything
> > > for Python.
> >
> > You're creating the label without a parent widget, so it becomes a
> > top-level window. Pass self to the constructor of QLabel and it works.
> 
> Slightly OT (in fact more a general question):
> 
> So it is possible to create a custom widget with PyQt4 and use it in 
> qt4-designer? 

Yes and now. It only works via the "Promote to Custom Widget" function,
which means using one of the existing widgets and place it into the
form, then choosing the "header" for the custom widget and the class via
a dialog. You won't see the custom widget in Qt4 designer, all you'll
see is the "standard" widget you placed into the form. 

pyuic4 then translates foobar.h into foobar.py and puts:

from foobar import FoobarClass

into the generated code. 

Real custom widgets are rather complicated, for Qt3 somebody managed to
have python-kparts which could be used in Python or C++ KDE apps which
is also a plugin...

Andreas

-- 
Never give an inch!




More information about the PyQt mailing list