[PyKDE] Using custom components and Qt Designer with QWidgetFactory in PyQt

Truls A. Tangstad kerfue+pykde at herocamp.org
Wed Nov 3 20:32:01 GMT 2004


On Wed, Nov 03, 2004 at 05:24:52PM +0000, Toby Dickenson wrote:
> On Wednesday 03 November 2004 16:55, Truls A. Tangstad wrote:
> > We use QWidgetFactory exclusively to generate the widgets runtime
> > from the .ui-files, and using pyuic would put us back into
> > gui-design stoneage again (gui mixed too much with other code, and
> > hard to redesign components).
> 
> Its always nice to hear about alternative techniques that make my
> current standard practice look stoneage... do you have any public
> documentation about how this works and why it is good?

I've seen surprisingly little documentation or examples about the use
of Qt Designer with QWidgetFactory, especially with PyQt. After we
found out about it we've been using it extensively making GUI work
exceptionally easier and code alot cleaner. We still have abit gui
code mixed in, especially connecting signals from the .ui-files to
local functions, but it's still alot better than before.

The principle is pretty much equal to using libglade and the glade
editor with GTK, which I experimented with before finding out about
the Qt equivalent.

> > Is there a way to use Qt Designer to embed python-created
> > components into dialogs etc. when they are loaded with
> > QWidgetFactory inty our python application? 
> 
> For the occasional custom widget on a pyuic form we either insert an
> empty QFrame and manually create the widget inside it, or insert a
> QLabel placeholder that gets manually replaced. All stoneage stuff I
> guess....

Do you mean by altering the generated sourcecode, or by
programmatically replacing the component? If it's the latter, I'd be
interested in knowing how to remove a placeholder-widget (i.e. a
QFrame) from a Qt Designer .ui-file at runtime, and replace it with a
custom widget, as that would go a long way to solve my problem.

-- 
Truls A. Tangstad - <kerfue+pykde at h e r o c a m p.org>




More information about the PyQt mailing list